Surfer,
First of all, you can massively simplify your form by purging all the nested tables.
<form action="<?php echo $editFormAction; ?>" id="insertForm" name="insertForm" method="POST">
<table width="375" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td colspan="3" align="center"><img src="../images/nc_title_logo.gif" width="342" height="54" /></td>
</tr><tr height="35" valign="bottom">
<td width="80%"><span class="style5">No Order completed in this call</span></td>
<td width="10%" align="center"><input name="noorder" type="checkbox" id="noorder" value="checkbox" onclick="toggle_visibility(['upsell', 'upsellBox', 'cross', 'crossBox'], 0, ['upsell', 'upsellStatus', 'cross', 'crossStatus']);" /></td>
<td width="10%"> </td>
</tr>
</tbody>
<tbody id="upsell" class="color-table">
<tr height="35" valign="bottom">
<td> </td>
<td align="center"><strong>YES</strong></td>
<td align="center"><strong>NO</strong></td>
</tr><tr>
<td>1) Did you attempt an Upsell?</td>
<td align="center"><input type="radio" name="upsell" value="Y" onclick="toggle_visibility('upsellBox', 1, 'upsellStatus');"/></td>
<td align="center"><input type="radio" name="upsell" value="N" onclick="toggle_visibility('upsellBox', -1, 'upsellStatus');"/></td>
</tr>
</tbody>
<tbody id="upsellBox" class="color-table">
<tr>
<td>2) Was the Upsell successful? </td>
<td align="center"><input type="radio" name="upsellStatus" value="Y" /></td>
<td align="center"><input type="radio" name="upsellStatus" value="N" /></td>
</tr>
</tbody>
<tbody id="cross" class="color-table-2">
<tr height="35" valign="bottom">
<td> </td>
<td align="center"><strong>YES</strong></td>
<td align="center"><strong>NO</strong></td>
</tr><tr>
<td>3) Did you attempt a Cross-Sell? </td>
<td align="center"><input type="radio" name="cross" value="Y" onclick="toggle_visibility('crossBox', 1, 'crossStatus');"/></td>
<td align="center"><input type="radio" name="cross" value="N" onclick="toggle_visibility('crossBox', -1, 'crossStatus');"/></td>
</tr>
</tbody>
<tbody id="crossBox" class="color-table-2">
<tr>
<td>4) Was the Cross-Sell successful? </td>
<td align="center"><input type="radio" name="crossStatus" value="Y" /></td>
<td align="center"><input type="radio" name="crossStatus" value="N" /></td>
</tr>
</tbody>
<tbody>
<tr height="35" valign="bottom">
<td> </td>
<td colspan="2" align="center"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</tbody>
</table>
<input type="hidden" name="MM_insert" value="insertForm">
<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 type="hidden" name="inqueue" id="inqueue" value="<?php echo $_GET['inqueue']; ?>" />
<input type="hidden" name="skill" id="skill" value="<?php echo $_GET['skill']; ?>" />
<input type="hidden" name="skillname" id="skillname" value="<?php echo $_GET['skillname']; ?>" />
<input type="hidden" name="contactid" id="contactid" value="<?php echo $_GET['contactid']; ?>" />
<input type="hidden" name="masterid" id="masterid" value="<?php echo $_GET['masterid']; ?>" />
<input type="hidden" name="dnis" id="dnis" value="<?php echo $_GET['dnis']; ?>" />
<input type="hidden" name="ani" id="ani" value="<?php echo $_GET['ani']; ?>" />
</form> Notes: is used to make addressable portions of a single table.
Judicious use of obviates the need for spacing rows in the table.
In Javascript, I have reduced your three functions for toggling sections on/off to just one. It's parameters control the behaviour including the unchecking of associated radio buttons, which is achieved by calling a second function.
function toggle_visibility(idArray, force, radioNamesArray) {
force = (!force) ? null : (force <= -1) ? 'none' : 'block';
if(typeof idArray == 'string'){ idArray = [idArray]; }//if string, then convert to array
if(radioNamesArray){ uncheck(radioNamesArray); }
for(var i=0; i<idArray.length; i++) {
var e = (document.getElementById) ? document.getElementById(idArray[i]) : document.all[idArray[i]];
if(force){ e.style.display = force; }
else{ e.style.display = (e.style.display == 'none') ? 'block' : 'none'; }
}
}
function uncheck(radioNamesArray) {
if(typeof radioNamesArray == 'string'){ radioNamesArray = [radioNamesArray]; }//if string, then convert to array
var elements = document.getElementsByTagName('input');
for(var i=0; i<elements.length; i++) {
for(var j=0; j<radioNamesArray.length; j++) {
if(elements[i].name && elements[i].name == radioNamesArray[j]) {
elements[i].checked = 0;
}
}
}
} You may need to readdress classes. I may have over-simplified things by moving all class definitions from s to tags.
Anyways, I hope this helps.Airchow
Airshow
WiFi Lounge Lizard
Moderator
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372