Hi!
I'm new to scripting (though I've had experience with programming and graphics). For my first site, I'm having problems with JavaScript in Firefox and Safari.
It seems that JavaScript works fine for normal functions, it launches the "confirm" box and all... but whenever I try to use JavaScript to change a value of an item that does not belong to the same function, an error is generated. Strangely, these errors are only generated in Firefox and Safari. The script works fine in Internet Explorer and Opera.
For example, if I use this code, it doesn't work:
Code:
<head>
<title>Untitled Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- nameClick() function definition -->
<script type="text/javascript">
function nameClick(nm)
{
var name1 = nm;
Button1.value = "Clicked!"; //Does not work in Firefox and Safari
}
</script>
</head>
<body>
<input onclick="nameClick('Hello')" id="Button1" type="submit" value="nameClick" />
</body>
You might say there is a flaw in my code, but the same is true for codes right out of MSDN's online help. Take a look at this code. Same problem.
Code:
<head>
<script type="text/jscript">
function CookieGroup()
{
txtOutput.value = window.event.srcElement.value;
}
</script>
</head>
<body>
<!-- Controls are grouped by giving them the same NAME but unique IDs. -->
<p>Grouped Radio Buttons<br>
<input type="radio"
name="rdoTest"
id="Cookies"
value="accept_cookies"
checked
onclick="CookieGroup()"><br>
<input type="radio"
name="rdoTest"
id="NoCookies"
value="refuse_cookies"
onclick="CookieGroup()"><br>
</p>
<p>Ungrouped Radio Button<br>
<input type="radio"
name="rdoTest1"
value="chocolate-chip_cookies"
onclick="CookieGroup()"><br>
</p>
<p>Value of control on which the onclick event has fired<br>
<textarea name="txtOutput" style="width: 250px"></textarea> </p>
</body>
So does anyone know WHY this happens? Is there any known way to fix this?
Thanks! 
Last edited by uttaresh; 08-04-2008 at 06:49 PM..
|