Welcome to WebmasterWorld Guest from 54.224.57.95

Forum Moderators: incrediBILL

Message Too Old, No Replies

onclick varies between browsers

my onclick works in ie not in Chrome or Firefox

     
3:59 pm on Sep 23, 2012 (gmt 0)



Is there a routine explanation for this or what

Typically I have

function f_button()
{alert("hello")}
.
.
.
<INPUT TYPE="radio" name="radiobuttons" id="radiobutton3" VALUE=0 onClick="f_button()">


The alert fires in IE but not in Chrome or Firefox

Thanks
Bill
11:15 pm on Sep 23, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Off the top of my head without detour to experiment:

#1 CASE
#2 Quotation marks

All versions of IE, Chrome, FF, or just whichever copy you currently have on your own computer?
1:42 pm on Sep 24, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



The following works for me in all browsers:

<html>
<head>
<title>
Test
</title>
</head>
<body>
<form action="">
<div>
<INPUT TYPE="radio" name="radiobuttons" id="radiobutton3" VALUE=0 onClick="f_button()">
</div>
</form>
<script>
function f_button() {
alert("hello");
}
</script>
</body>
</html>

Note, however, that I would not use inline event handlers. Instead, attach event listeners via the script code... don't muddle your HTML with scripting content.
Also, you should consider cleaning up your code with respect to what lucy24 pointed out. You've got mixed case, and inconsistent use of quotes around HTML attribute values. Your code should look more like this when cleaned up:


<input type="radio" name="radiobuttons" id="radiobutton3" value="0" onclick="f_button();">
3:08 pm on Sep 24, 2012 (gmt 0)



Thank you both.

I have it working now with 'case' burned into my fingertips!

Bill
 

Featured Threads

Hot Threads This Week

Hot Threads This Month