PDA

View Full Version : Broken in netscape


Justin Ba
02-05-2003, 08:28 PM
In Netscape (4 and 7) the pictures borders dont change on click... in IE6 it works like a charm...
ps, i highlighted the important parts, and the space between java and script in the href is added by the forum, its not in my code... please advise! much thanks in advance!

<form name="Form1" action="picturesurvey.asp?id=2&pid=1" method="post">
<input type="hidden" name="strImageSelected">
<table>
<tr>
<td>
<a href="javascript:SelectImage(1);"><img name="Image1" src="beveled-curved1.jpg" border="0"></a>
</td>
<td>
<a href="javascript:SelectImage(4);"><img name="Image4" src="beveled-curved2.jpg" border="0"></a>
</td>
</tr>
<tr>
<td colspan=3 align=center>
<input class="buttonstyle" type="button" name="Back" value="Back" onclick="back();">
<input class="buttonstyle" type="submit" name="Next" value="Next" onclick="return validate(this.form);">
</td>
</tr>
</table>
</form>
</body>
<script id=javascript>
var nSelectedImage;
function SelectImage(nImage) {
switch (nImage) {
case 1: {
for (i=0;i<document.images.length;i++) {
var tempobj=document.images[i];
}
document.Image1.style.border='4 groove #0000b0';
nSelectedImage=1;
document.Form1.strImageSelected.value=1;
break;
}
case 4: {
for (i=0;i<document.images.length;i++) {
var tempobj=document.images[i];
}
document.Image4.style.border='4 groove #0000b0';
nSelectedImage=4;
document.Form1.strImageSelected.value=4;
break;
}
}
}

beetle
02-05-2003, 08:30 PM
Uhh, try moving your <script> block to inside the <head> and not outside the <body>

Did somebody tell you to put it there? It don't belong there!

Justin Ba
02-05-2003, 08:37 PM
thanks, I do know that it belongs in the head... however the code is dynamically created through ASP and some of the variables creating it wern't initialized yet at the head, so for the short term, i just moved the script down to the end of the page.

While that could obviously cause problems, i dont think that is the case this time, because if the user clicks a picture, the strImageSelected field is popluated meaning at least "part" of the JS is working :)

I'll go ahead and end my lazyness and put it where it belongs, but the question still stands :)

brothercake
02-05-2003, 09:00 PM
Beetle is quite right - the <body> tag is not arbitrary, it encloses a branch of the HTML node tree - in other words, your calls to document.collection are broken, because the script isn't in the document.

IE lets you off with that kind of thing; Gecko browsers don't. I suggest you try and see if that makes it work - if it does, well, that's the answer to the question.

Justin Ba
02-05-2003, 11:13 PM
Moved it to the head... got it working again in IE (just initialized certain variables sooner).. and still doesnt work in Netscape...

the code is no different, so i wont repost it.

Justin Ba
02-06-2003, 12:03 AM
Incase anybody cares...

the problem was NS doesn't assume the px in the style

"4 groove blue"

it must be in the format

"4px groove blue" or none of the params work.