tags:

views:

23

answers:

3
  <input type="radio" name="regenerate" value="1" id="cus" />
         <input type="radio" name="regenerate" value="2" id="gen" />
         <input type="checkbox" name="renerateEmail" id="renerateEmail" />
     <div id="txt" style="display:none"><input type="password" name="pass" id="pass" /><br />
     <input type="password" name="repass" id="repass" /></div>

i want to hide and show the div "txt" when radio button has the value 1 , how can i do that.

A: 

You request isn't clear. Do you want to hide the div when the radio button is 1 and show it when it's 2? Or what?

You want something like:

if ($("#cus:checked").length == 1) {
  $("#txt").show();
}
Paul Schreiber
A: 

"hide and show".. "has the value 1" - ?not precisely clear what you want but .. here's one way

$(':radio[name=regenerate]').click(function() {
  if ($(':radio[name=regenerate]:checked').val() == 1)
    $('#txt').show()
  else
    $('#txt').hide();
})
Scott Evernden
+1  A: 

maybe this

$("input[name=regenerate]").click(function(){
    if($(this).val() == 1) {
        $("#txt").show();
    } else {
        $("#txt").hide();
    }
});
rob waminal