mac007 Posted June 18, 2009 Share Posted June 18, 2009 I have the folloiwing javascript "hide/show" code, that shows a user specific checkboxes depending on what gets clicked... problem is, any clicked checkboxes that are within these "hide/show" divs retain their checked values even if one hides them... so, seems javascript is simply hiding whole selected "checkbox" and sending value thru anyways.. So, do I need DOM-Javascript? so actual divs are completely removed or added? But I'm not a javascript guy, and I'm havign a hard time modifyign this to do that... Appreciate any help! here's javascript: <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 HTML FORM 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> Link to comment https://forums.phpfreaks.com/topic/162785-hideshow-vs-addremove-checked-boxes-retain-value-even-if-hidden-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.