0

i have an image tag in struts2. i want to check if a radiobutton is checked or not as its onclick() event..pls help me.

image tag:

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

radiobutton:

<s:iterator status="stat" value="modNameList">
                  <s:radio list="moduleName" name="modNameCheck" id="modNameCheckId"/>
                  <br>
                </s:iterator>
Yagnesh Agola
  • 4,556
  • 6
  • 37
  • 50
user1776488
  • 59
  • 3
  • 14

2 Answers2

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

}
0

This Example may help you :

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

You can find more about this here !

Community
  • 1
  • 1
Yagnesh Agola
  • 4,556
  • 6
  • 37
  • 50