Insomniac_PhD
asked on
Toggle row with javascript in asp
The following code should toggle an additional row for each record. However it only toggles the first row. If I check the checkbox on any record, the first record toggles only.
<script language="JavaScript">
function toggle(target)
{
obj=document.getElementByI d(target);
obj.style.display=( (obj.style.display=='none' ) ? '' : 'none');
}
</script>
<input style="display:inline" type="checkbox" onClick="toggle('therow')" id=checkbox1 name=checkbox1>
<tr id="therow" style="display:none" bgcolor="<%= bgcolor %>">
<td colspan="9"><span class="aspmaker"><%=Subjec tLine%></s pan> </td>
</tr>
<%
End If
rs.MoveNext
Loop
%>
<script language="JavaScript">
function toggle(target)
{
obj=document.getElementByI
obj.style.display=( (obj.style.display=='none'
}
</script>
<input style="display:inline" type="checkbox" onClick="toggle('therow')"
<tr id="therow" style="display:none" bgcolor="<%= bgcolor %>">
<td colspan="9"><span class="aspmaker"><%=Subjec
</tr>
<%
End If
rs.MoveNext
Loop
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your checkboxes should look like this
<input style="display:inline" type="checkbox" onClick="toggle('therow')" id=checkbox1 name=checkbox1>
<input style="display:inline" type="checkbox" onClick="toggle('therow1') " id=checkbox1 name=checkbox1>
<input style="display:inline" type="checkbox" onClick="toggle('therow2') " id=checkbox1 name=checkbox1>
Since you will be dynamically creating the table row id <tr id = "throw"+i>
you just need to pass the same dynamic value to onClick="toggle("
<input style="display:inline" type="checkbox" onClick="toggle('therow')"
<input style="display:inline" type="checkbox" onClick="toggle('therow1')
<input style="display:inline" type="checkbox" onClick="toggle('therow2')
Since you will be dynamically creating the table row id <tr id = "throw"+i>
you just need to pass the same dynamic value to onClick="toggle("
ASKER
Got it! I just used the record key as the dynamic reference.
Thanks.
Thanks.
Thanks for the points and grade
ASKER