Hi there
I have a set of radio buttons that are generated dynamically,I never know how many sets of radio buttons will be generated, so i need to validate that one of the radio buttons of each set is checked.
I'm pretty new at javascript so if somebody could tell me what's wrong with this code I would apreciate very much
thanx
</body>
<SCRIPT LANGUAGE="JavaScript">
function validate(ivalue){
for(x = 0; x < ivalue.length; x++) {
if (document.status.ivalue[x].checked == false) {
alert("Error"
;
return false;
}
}
}
</SCRIPT>
<body>
<FORM ACTION="" METHOD="post" NAME="status" ONSUBMIT="validate(this)"><tr>
<input type=radio name='ship' value='SH| 22'>Shipped</td>
<input type=radio name='ship' value='BO| 22'>Back Order</td>
</tr>
<tr>
<input type=radio name='ship1' value='SH| 23'>Shipped</td>
<input type=radio name='ship1' value='BO| 23'>BackOrder</td>
</tr>
<tr>
<input type=radio name='ship2' value='SH| 24'>Shipped</td>
<input type=radio name='ship2' value='BO| 24'>BackOrder</td>
</tr>
</form>
I have a set of radio buttons that are generated dynamically,I never know how many sets of radio buttons will be generated, so i need to validate that one of the radio buttons of each set is checked.
I'm pretty new at javascript so if somebody could tell me what's wrong with this code I would apreciate very much
thanx
</body>
<SCRIPT LANGUAGE="JavaScript">
function validate(ivalue){
for(x = 0; x < ivalue.length; x++) {
if (document.status.ivalue[x].checked == false) {
alert("Error"
return false;
}
}
}
</SCRIPT>
<body>
<FORM ACTION="" METHOD="post" NAME="status" ONSUBMIT="validate(this)"><tr>
<input type=radio name='ship' value='SH| 22'>Shipped</td>
<input type=radio name='ship' value='BO| 22'>Back Order</td>
</tr>
<tr>
<input type=radio name='ship1' value='SH| 23'>Shipped</td>
<input type=radio name='ship1' value='BO| 23'>BackOrder</td>
</tr>
<tr>
<input type=radio name='ship2' value='SH| 24'>Shipped</td>
<input type=radio name='ship2' value='BO| 24'>BackOrder</td>
</tr>
</form>