Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check checkbox values

Status
Not open for further replies.

RicardoPereira

Programmer
Jun 3, 2003
255
PT
How do i check if one of checkboxes is not selected ?
 
As you see i'm not an expert in javascript. How it should be if the checkbox is dynamic ?

Here is my code:

Code:
<form name='teste' method='GET' action='test_resp.jsp' target='bottom'>
<%
ArrayList tt_entLinhas=form.getTT_EntLin(sClienteDef,sReferencia.trim());
    for( int y=0;y<tt_entLinhas.size();y++) 
	  {
        LogiCeasy.TrackTrace.QryEntLin qryEntLin=(LogiCeasy.TrackTrace.QryEntLin) tt_entLinhas.get(y);
out.println("<tr><td><input type='checkbox' name='test' value=" + qryEntLin.getE4lig() + " checked></td><td>" + qryEntLin.getE4art() + 
"</td><td>" + qryEntLin.getE4lig() + 
"</td><td align=center>" + qryEntLin.getE4qapp() + "");
out.println("</td></tr>");
}
%>
<tr align=left><th colspan=4><button id='check' class="submit">Completa</button>&nbsp;<button id='uncheck' onclick='uncheckAll(this.form)' class="submit">Parcial</button></th></tr>
<center>
<tr><td colspan='4' align='left'>
<input type="submit" value="Submeter" class="formButton">

Thanks
 
I didn't put, but is before the code i wrote.
Your code works if the checkbox is static. Where do i put if it's dynamic ?

Code:
<script type='text/javascript'><!-- 
function checkAll(form) { 
  setCheckedState(form, true); 
} 

function uncheckAll(form) { 
  setCheckedState(form, false); 
} 

//--> 
</script>
<form name='teste' method='GET' action='test_resp.jsp' target='bottom'>
<%
ArrayList tt_entLinhas=form.getTT_EntLin(sClienteDef,sReferencia.trim());
    for( int y=0;y<tt_entLinhas.size();y++) 
      {
        LogiCeasy.TrackTrace.QryEntLin qryEntLin=(LogiCeasy.TrackTrace.QryEntLin) tt_entLinhas.get(y);
out.println("<tr><td><input type='checkbox' name='test' value=" + qryEntLin.getE4lig() + " checked></td><td>" + qryEntLin.getE4art() + 
"</td><td>" + qryEntLin.getE4lig() + 
"</td><td align=center>" + qryEntLin.getE4qapp() + "");
out.println("</td></tr>");
}
%>
<tr align=left><th colspan=4><button id='check' class="submit">Completa</button>&nbsp;<button id='uncheck' onclick='uncheckAll(this.form)' class="submit">Parcial</button></th></tr>
<center>
<tr><td colspan='4' align='left'>
<input type="submit" value="Submeter" class="formButton">
 
you will need to loop through each form element, check whether the element is a checkbox, then check to make sure it's not the "Parcial" checkbox, then go from there...

Code:
var allElements = myForm.elements;
for ( var i = 0; i < allElements.length; i++ ) {
    if (allElements[i].type == 'checkbox' )
        allElements[i].checked = false;
}

the above code will loop through all elements in a form element stored in the myForm variable. if the element is a checkbox, it will uncheck it.



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top