2012-11-01 163 views
0

我在struts2中有一个图像标记。我想检查一个单选按钮是否被检查,因为它的onclick()事件..请帮助我。检查是否在struts2中检查了某个单选按钮。

图片标签:

<input type="image" src="../image/edit.jpg" alt="img" width="25" height="25" value="Edit" name="moduleMenu"/> 

单选:

<s:iterator status="stat" value="modNameList"> 
        <s:radio list="moduleName" name="modNameCheck" id="modNameCheckId"/> 
        <br> 
       </s:iterator> 
+0

你想检查它在服务器端还是客户端? –

+0

你想检查单击图像标签或单选按钮的单选按钮状态? – anu

+0

@ anu:图片标签 – user1776488

回答

0

这个实例可以帮助你:

var moduleNameRadio=document.getElementsByName("modNameCheck"); 

for(var i=0;i<moduleNameRadio.length;i++) 
{ 
     if(moduleNameRadio[i].checked){ 
      alert('Radio button selected'); 
      //Add your code here.... 
     } 
} 

你可以找到更多关于这个here

1
<s:iterator status="stat" value="modNameList"> 
        <s:radio list="moduleName" name="modNameCheck" id="modNameCheckId" onclick = "validate(this.value)" /> 
        <br> 
       </s:iterator> 

<script> 
function validate(value){ 
alert(value); 

} 

</script> 
//or u can pass this.id 

<s:iterator status="stat" value="modNameList"> 
        <s:radio list="moduleName" name="modNameCheck" id="modNameCheckId" onclick = "validate(this.id)" /> 
        <br> 
       </s:iterator> 

<script> 
function validate(id){ 
alert(id); 

} 
相关问题