Hi, all:
I got a form where some checbox fields will hide or show as user clicks specific choices. Problem is, if one mistakenly checks one of these checkboxes and then hides it, it still does retain the checked value, even if hidden. How can I make sure that the checkbox defaults back to "unchecked" if in fact is "hidden"??
Here's my javascript code:
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}
//-->
</script>
<script type="text/javascript">
<!--
function toggle_visibilityNone(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'none';
}
//-->
</script>
<script type="text/javascript">
<!--
function toggle_visibilityYes(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'block';
}
//-->
</script>
and here is my basic form-html code:
<form action="<?php echo $editFormAction; ?>" id="insertForm" name="insertForm" method="POST">
<p> </p>
<table width="375" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="center"><img src="../images/nc_title_logo.gif" width="342" height="54" /></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td width="314"><span class="style5">No Order completed in this call </span></td>
<td width="61" colspan="2" align="center">
<input name="noorder" type="checkbox" id="noorder" value="checkbox" onclick="toggle_visibility('box');" /> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><div id="box">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="color-table">
<td > </td>
<td align="left"> </td>
<td align="left"> </td>
</tr>
<tr class="color-table">
<td > </td>
<td align="left"><strong>YES</strong></td>
<td align="left"><strong>NO</strong></td>
</tr>
<tr>
<td width="80%" class="color-table"> 1) Did you attempt an Upsell?</td>
<td class="color-table"><input type="radio" name="upsell" value="Y" onclick="toggle_visibilityYes('upsellBox');"/></td>
<td align="center" class="color-table"><input type="radio" name="upsell" value="N" onclick="toggle_visibilityNone('upsellBox');"/></td>
</tr>
</table></td>
</tr>
<tr>
<td class="color-table"> </td>
</tr>
<tr>
<td class="color-table"><div id="upsellBox">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80%" class="color-table"> 2) Was the Upsell successful? </td>
<td class="color-table"><input type="radio" name="upsellStatus" value="Y" /></td>
<td align="center" class="color-table"><input type="radio" name="upsellStatus" value="N" /></td>
</tr>
<tr>
<td class="color-table"> </td>
<td class="color-table"> </td>
<td align="center" class="color-table"> </td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td class="color-table-2"> </td>
</tr>
<tr>
<td class="color-table-2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="color-table-2"> </td>
<td align="left" class="color-table-2"><strong>YES</strong></td>
<td colspan="2" align="left" class="color-table-2"><strong>NO</strong></td>
</tr>
<tr>
<td width="80%" class="color-table-2"> 3) Did you attempt a Cross-Sell? </td>
<td class="color-table-2"><input type="radio" name="cross" value="Y" onclick="toggle_visibilityYes('crossBox');"/></td>
<td colspan="2" align="center" class="color-table-2"><input type="radio" name="cross" value="N" onclick="toggle_visibilityNone('crossBox');"/></td>
</tr>
</table></td>
</tr>
<tr>
<td class="color-table-2"> </td>
</tr>
<tr>
<td><div id="crossBox">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80%" class="color-table-2"> 4) Was the Cross-Sell successful? </td>
<td class="color-table-2"><input type="radio" name="crossStatus" value="Y" /></td>
<td align="center" class="color-table-2"><input type="radio" name="crossStatus" value="N" /></td>
</tr>
<tr>
<td class="color-table-2"> </td>
<td class="color-table-2"> </td>
<td align="center" class="color-table-2"> </td>
</tr>
</table>
</div></td>
</tr>
</table>
</div> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td><input name="agentid" type="hidden" id="agentid" value="<?php echo $_GET['agentid']; ?>" />
<input name="first" type="hidden" id="first" value="<?php echo $_GET['first']; ?>" />
<input name="last" type="hidden" id="last" value="<?php echo $_GET['last']; ?>" />
<input name="startdate" type="hidden" id="startdate" value="<?php
$newdate = $_GET['startdate'];
$newdateMonth = substr($newdate,0,2);
$newdateDay = substr($newdate,2,2);
$newdateYear = substr($newdate,4,4);
$newFinalDate = $newdateYear . "-" . $newdateMonth . "-" . $newdateDay;
echo $newFinalDate;
?>" />
<input name="inqueue" type="hidden" id="inqueue" value="<?php echo $_GET['inqueue']; ?>" />
<input name="skill" type="hidden" id="skill" value="<?php echo $_GET['skill']; ?>" />
<input name="skillname" type="hidden" id="skillname" value="<?php echo $_GET['skillname']; ?>" />
<input name="contactid" type="hidden" id="contactid" value="<?php echo $_GET['contactid']; ?>" />
<input name="masterid" type="hidden" id="masterid" value="<?php echo $_GET['masterid']; ?>" />
<input name="dnis" type="hidden" id="dnis" value="<?php echo $_GET['dnis']; ?>" />
<input name="ani" type="hidden" id="ani" value="<?php echo $_GET['ani']; ?>" />
</td>
<td colspan="2" align="center"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="insertForm">
</form>