1

I have written a js method which runs perfectly on FF. This js method is called on the click of a radio button.

In IE, when I click the radio button, the js method is called only when I click somewhere on the form. I have no idea about this strange behavious in IE.

Any ideas?

Thx


Here is my code.

xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"

HTML CODE:

<h:selectOneRadio  id="pid" value="#{Bean.pid}" onchange="javascript:checkPid();">    
<f:selectItem itemLabel="label1" itemValue="value1"/> 
<f:selectItem itemLabel="label2" itemValue="value2" /> 
<f:selectItem itemLabel="label3" itemValue="value3" /> 
</h:selectOneRadio>

JAVASCRIPT:

<script language="javascript" type="text/javascript">

function checkPid() {
   //some basic js here
   //even if I just give an one-liner alert stmt here, In IE it 
   //shows up only when I click somewhere on the form after I click 
   //on the radio button
}

Thanks in advance!

4
  • 7
    Are you talking about the change event for radios? In FF, a radio's value is changed right after you click it. But it seems that in IE, the value is considered "changed" after it's clicked & loses focus. Commented Aug 13, 2010 at 6:50
  • Can you post some code. Include your HTML and JavaScript, otherwise its virtually impossible to help. Commented Aug 13, 2010 at 7:10
  • Why support Internet Explorer? IE support is a vicious cycle that can only be stopped by the developer first. If we continue its support, users will have no incentive to change browsers, and this will go on forever, or at least until Microsoft releases a decent browser (IE9, a complete rewrite, is actually quite nice). For now, however, the 55% of internet users using IE will have to face a slightly-harsh truth, and move on. Commented Aug 13, 2010 at 8:37
  • the "HTML" you posted is not html. It's jsf markup. Please "view source" in your browser to see what HTML is actually being generated by this markup. Commented Nov 11, 2010 at 3:08

1 Answer 1

1

Try the onclick event rather than the onchange event.

You'll need to modify your code though:

<h:selectOneRadio  id="pid" value="#{Bean.pid}" onclick="checkPid(this);">    

And your javascript function:

function checkPid(e) {
   //do stuff with e.value
}

You should be able to validate what the user clicked on by e.value. This should work for both browsers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.