Form visibility setting in NS7.1 works and does not in NS7.2

Need technical advice on coding your web pages? Covers HTML, JavaScript, CSS, and some server side technologies. Also the issue of some webpages not displayed well.

Moderator: Don_HH2K

Form visibility setting in NS7.1 works and does not in NS7.2

Postby tjb » Tue 25 Apr, 2006 2:29 pm

I hope somebody can help I have a form that works in NS7.1 and NS8 - I need it to work in NS7.2

The problem is the setting of a form field visible when a check box is checked the form looks like:

<FORM ACTION="orderformdone.php" METHOD="POST" ID="orderform" name="orderform">
<table border="0" width="70%" align="center" cellpadding="0" cellspacing="0" class=maintext>
<tr>
<td><INPUT type="checkbox" name="spray" onClick="togField( \'textBox1\' );"><font color="#000099"> Spray</font></td>
<td><font color="#000099">6601</font></td>
<td><font color="#000099">1 x 50ml spray</font></td>
<td><INPUT type=text name=textBox1 size="5" onFocus="startCalc();" onBlur="stopCalc();"</td>
</tr>
</table>
</form>

The togField function looks like:
function togField(id) {
if (document.all[ id ].style.visibility != "hidden") {
document.all[ id ].value = '0'
calc();
document.all[ id ].style.visibility = 'hidden';
}
else {
document.all[ id ].style.visibility = 'visible'
document.all[ id ].value = '6'
document.all[ id ].focus();
document.orderform.Total.style.visibility = "visible";
}
}

The code works on FireFox, Opera etc etc.

Any clues would be appreciated.

Rgds

TJB.
UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; en-GB) Opera 8.50
tjb
new member
new member
 
Posts: 1
Joined: Tue 25 Apr, 2006 2:12 pm

Postby akbash » Thu 27 Apr, 2006 11:04 am

I don't have 7.2 to test against on my own machine, but I can tell you that document.all is never a good way to get what you want. It will always cause compatibility problems. Something like this should work:
Code: Select all
<html><head>
<script>
function togField(field) {
  field.style.visibility = field.style.visibility == "hidden" ?
                           "visible" : "hidden";
}
</script>
</head><body>
<form>
  <input type="checkbox" name="spray" onClick="togField(textBox1)">Spray
  <input type="text" name="textBox1" size="5"
</form>
</body>
</html>
UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20060305 Firefox/1.5
akbash
silver member
silver member
 
Posts: 364
Joined: Mon 09 Feb, 2004 9:13 pm


Return to Web Design and Page Coding

Who is online

Registered users: Google [Bot]

cron