I have a set of records with a checkbox before each of them. Depending on a particular condition, there may be 2 radio buttons after each value(e.g. Record1). For records with radio buttons, I would like to ensure if the checkbox is checked for a record and then one of the following radio buttons should be checked too.
Thank you for your help in advance. Here is the code I have so far.
PK
<SCRIPT LANGUAGE='JavaScript'>
function checkEntry(form) {
var sel = false;
with (document.updateForm)
{
for (var i=0; i<elements.length; i++)
{
if(elements.type==checkbox && elements.checked==true)
{
if(elements[i+1].type==radio)
{
if(elements[i+1].checked==false && elements[i+2].checked==false)
{
alert("Please select an update option.")
elements[i+1].focus()
break
}
}
}
alert(elements.type)
break
}
}
if (sel == false)
{
return(false);}
}
</SCRIPT>
<form NAME="updateForm" METHOD="POST" ACTION="includes/update.asp" onSubmit="return checkEntry(this)">
<input type='checkbox' name=DBVar20 value= 'ON' >
Record1
<input type='radio' value='2' name=R_DBVar20 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar20 ><img border='0' src='images/downGreen.gif'>
<br>
<input type='checkbox' name=DBVar23 value= 'ON' >
Record2
<input type='radio' value='2' name=R_DBVar23 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar23 ><img border='0' src='images/upGreen.gif'>
<br>
<input type='checkbox' name=DBVar24 value= 'ON' >
Record3
<input type='radio' value='2' name=R_DBVar24 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar24 ><img border='0' src='images/upGreen.gif'>
<br>
<input type='checkbox' name=DBVar27 value= 'ON' >
Record4
<input type='radio' value='2' name=R_DBVar27 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar27 ><img border='0' src='images/upGreen.gif'>
<br>
<input type="button" value="Cancel" name="Cancel" >
<input type="submit" value="Update" name="updateForm">
</form>
Thank you for your help in advance. Here is the code I have so far.
PK
<SCRIPT LANGUAGE='JavaScript'>
function checkEntry(form) {
var sel = false;
with (document.updateForm)
{
for (var i=0; i<elements.length; i++)
{
if(elements.type==checkbox && elements.checked==true)
{
if(elements[i+1].type==radio)
{
if(elements[i+1].checked==false && elements[i+2].checked==false)
{
alert("Please select an update option.")
elements[i+1].focus()
break
}
}
}
alert(elements.type)
break
}
}
if (sel == false)
{
return(false);}
}
</SCRIPT>
<form NAME="updateForm" METHOD="POST" ACTION="includes/update.asp" onSubmit="return checkEntry(this)">
<input type='checkbox' name=DBVar20 value= 'ON' >
Record1
<input type='radio' value='2' name=R_DBVar20 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar20 ><img border='0' src='images/downGreen.gif'>
<br>
<input type='checkbox' name=DBVar23 value= 'ON' >
Record2
<input type='radio' value='2' name=R_DBVar23 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar23 ><img border='0' src='images/upGreen.gif'>
<br>
<input type='checkbox' name=DBVar24 value= 'ON' >
Record3
<input type='radio' value='2' name=R_DBVar24 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar24 ><img border='0' src='images/upGreen.gif'>
<br>
<input type='checkbox' name=DBVar27 value= 'ON' >
Record4
<input type='radio' value='2' name=R_DBVar27 ><img border='0' src='images/blueStar.gif'>
<input type='radio' value='1' name=R_DBVar27 ><img border='0' src='images/upGreen.gif'>
<br>
<input type="button" value="Cancel" name="Cancel" >
<input type="submit" value="Update" name="updateForm">
</form>