homepage Welcome to WebmasterWorld Guest from 54.204.231.253
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
onclick varies between browsers
my onclick works in ie not in Chrome or Firefox
bs6600




msg:4498850
 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

 

lucy24




msg:4499010
 11:15 pm on Sep 23, 2012 (gmt 0)

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?

Fotiman




msg:4499340
 1:42 pm on Sep 24, 2012 (gmt 0)

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();">

bs6600




msg:4499371
 3:08 pm on Sep 24, 2012 (gmt 0)

Thank you both.

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

Bill

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved