开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜