i know this a jscript q - but have a nice function
that show/hides table rows, the problem is because
this is a dynamic table populated from db.
this is a list of makes in stock with respective models listed beneath. i want the model rows to be hidden until a user clicks 'show' button and then the models are displayed.
at the moment the code only works with the first make in the list. i am surprised that all the rows in the table dont show/hide.
let me know if im talking rubbish and i will try to explain better. also i dont think i need two loops for this so it is a messy way of ding this.
that show/hides table rows, the problem is because
this is a dynamic table populated from db.
this is a list of makes in stock with respective models listed beneath. i want the model rows to be hidden until a user clicks 'show' button and then the models are displayed.
at the moment the code only works with the first make in the list. i am surprised that all the rows in the table dont show/hide.
let me know if im talking rubbish and i will try to explain better. also i dont think i need two loops for this so it is a messy way of ding this.
Code:
<script language="javascript" type="text/javascript">
function FuncShowHide(){
if (document.getElementById('hideShow').style.display == document.getElementById('trX').style.display){
document.getElementById('hideShow').style.display = "none";
} else {
document.getElementById('hideShow').style.display = document.getElementById('trX').style.display
}
}
</script>
modsql = "SELECT count(stock.model) AS modcount, stock.model, stock.make "_
& "FROM stock "_
& "GROUP BY model "_
& "ORDER BY model"
countsql = "SELECT count(stock.make) AS makecount, stock.make AS makeid, make.make AS makequick "_
& "FROM stock "_
& "INNER JOIN make on make.makeid = stock.make "_
& "GROUP BY makeid"
Set rsmakecount = Server.CreateObject("ADODB.Recordset")
rsmakecount.Open countsql, conn
response.Write("<table border=0 cellspacing=0 cellpadding=2>")
x_makecount=0
Do While (Not rsmakecount.Eof)
x_makeid = rsmakecount("makeid")
x_makequick = rsmakecount("makequick")
x_makecount = rsmakecount("makecount")
response.Write "<tr id=trX><td colspan=2><a href=3coltemp.asp?pagesetupid=2&x_Make=" & Server.URLEncode(x_makeid) & "&z_Make==,','><span class=quickfindlge>" & (x_makequick) & "</span></a></td><td><input name=showhide type=image onClick=FuncShowHide();chgimg(this);return false; src=images/showbut2.gif width=13 height=9></td><td><span class=quickfindlge>("& (x_makecount) & ")</span></td></tr>"
reccount=0
rsmod.Open modsql, conn
totrecs = rsmod.RecordCount
startrec = 1
lastrec = totrecs
Do While (Not rsmod.Eof)
reccount=reccount+1
if rsmod("make") = x_makeid then
x_modcount = rsmod("modcount")
x_mod = rsmod("model")
response.Write "<tr id=""hideshow"" style=""display: none;""><td><img src=images/spacer.gif width=5></td><td><a href=3coltemp.asp?pagesetupid=2&x_Model=" & Server.URLEncode(x_mod) & "&z_Model==,','&x_Make=" & Server.URLEncode(x_makeid) & "&z_Make==,','><span class=quickfind>" & (x_mod) & "</span></a></td><td></td><td><span class=quickfind>("& (x_modcount) & ")</span></td></tr>"
end if
rsmod.MoveNext
Loop
if reccount = lastrec then
rsmod.movefirst
end if
'end if
rsmakecount.MoveNext
Loop
rsmakecount.close
conn.Close
Set conn = Nothing
response.Write("</table>")