You are viewing limited content. For full access, please sign in.

Question

Question

Trying to find radio button selected value, but its not working

asked on January 29, 2016 Show version history

this javascript code is not working. when i debug it says $('.gender option:selected').val() is undefined. Please help

$(document).ready(function () {
  $('.cf-collection-block').on('blur', 'input', showresult);
  
  function showresult() {  
    if($('.gender option:selected').val() == 'Male')
       {
         $('.name input').val("Male");
       }
    else
    {
      $('.name input').val("Female");
    }
  }
  
});

0 0

Answer

SELECTED ANSWER
replied on January 29, 2016 Show version history

Try this instead:

$('.gender input:checked').val();

 

1 0

Replies

replied on January 29, 2016

Can you share a few more details about your form, possibly a screenshot from the "CSS and Javascript" tab?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.