Home>
<form>
    Are you a student?<br>
    <input type = "radio" name = "student" value = "I am a student">Yes
    <input type = "radio" name = "student" value = "not a student">No
    <br>
    <input type = "submit">
</form>


What if an if statement wants to check if value = "not a student" is checked? .

You can also get the value of the second name attribute. . .

php
  • Answer # 1

    JavaScript (jQuery)

    $('input [type = "radio"]'). click (function () {
      alert ($(this) .val ());
    });

    Sample

  • Answer # 2

    
    
        Are you a student?
        Yes     No     
        


    * Or instead of picking out what is checked
    If you just want to pick up the second value

    
    
        Are you a student?
        Yes     No     
        

Related articles