javascript - PHP show textbox on radiobutton click -


hi attaching part of code should hide textbox , when female selected should show it. not working

$(document).ready(function() {    $('input[name="gender"]').click(function() {      var value = $(this).val();      if( $value == "male")      {        $('#address').hide();      }      else{        $('#address').show();      }    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <style>  .error {color: #ff0000;}  </style>    gender:    <input type="radio" name="gender" value="female">female    <input type="radio" name="gender" value="male">male      <div name="address" id="address">  	  <textarea name="address" id="address" rows="5" cols="40"></textarea>  	</div>    <br><br>

please help.

you set value variable wrote $value in comparison test.

try this:

$(document).ready(function() {    $('input[name="gender"]').click(function()                                     {      var value = $(this).val();      if( value == "male")      {        $('#address').hide();      }      else{        $('#address').show();      }        });  });  </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <style>  .error {color: #ff0000;}  </style>  gender:    <input type="radio" name="gender" value="female">female    <input type="radio" name="gender" value="male">male      <div name="address" id="address">  	  <textarea name="address" id="address" rows="5" cols="40"></textarea>  	</div>    <br><br>

edit:

as pointed out in comments, snippet did not include jquery library, not work. make sure it's present in code. eg:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -