Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检查struts2中是否选中了单选按钮_Javascript_Jsp_Struts2 - Fatal编程技术网

Javascript 检查struts2中是否选中了单选按钮

Javascript 检查struts2中是否选中了单选按钮,javascript,jsp,struts2,Javascript,Jsp,Struts2,我在struts2中有一个图像标签。我想检查单选按钮是否作为其onclick()事件被选中。请帮助我 图像标签: <input type="image" src="../image/edit.jpg" alt="img" width="25" height="25" value="Edit" name="moduleMenu"/> 单选按钮: <s:iterator status="stat" value="modNameList">

我在struts2中有一个图像标签。我想检查单选按钮是否作为其onclick()事件被选中。请帮助我

图像标签:

<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>



此示例可能会帮助您:

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....
      }
}
var moduleNameeradio=document.getElementsByName(“modNameCheck”);
对于(变量i=0;i


函数验证(值){ 警报(值); } //或者你可以通过这个
函数验证(id){ 警报(id); }
要在服务器端还是客户端检查?要在单击图像标签或单选按钮时检查单选按钮状态?
<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);

}