简体   繁体   中英

IE8 Javascript Error

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM