I am using Struts1.3, and in this Jsp page dynamically generate check boxes depends on the data available in Database. my code which is generate check boxes is as follow
<table width="850" border="0" align="left" cellpadding="2" cellspacing="0">
<tr>
<td width="100" align="center" bgcolor="#F3F3F3"><label>
<html:checkbox name="ExporterForm" value="<%=authlist.get(i).getAuthorityid()%>" property="exportauthority" styleId="checkbox99" />
</label></td>
<td align="center" class="text_exp" ><%=authlist.get(i).getAuthorityname()%></td>
</tr>
</table>
I have one more check Box(selectAll), and query is, I want to mark checked all while selection of selectAll CheckBox.
and my code is for checked all check box is given below but it’s select only one and need to select all please show me the path to achieve it.
function selectAllAuthorites()
{
var selectAll=document.getElementById("checkbox101")
if(selectAll.checked==true)
{
document.getElementById("checkbox99").checked=true;
}
}
You can use getElementsByTagName method of Javascript.
This code might be of your help!
You can call this function from your html checkbox.
Edit:
these links might help you.
javascript-check-one-check-all-checkbox
Javascript Function to Check or Uncheck all Checkboxes
Another Link