Reputation: 43
<div class="form-group field-userform-custtype required">
<label class="control-label" for="custtype1">Custtype</label>
<input type="hidden" name="UserForm[custtype]" value="">
<div id="custtype1" class="flip">
<label class="radio-inline"><input type="radio" name="UserForm[custtype]" value="1"> B2C</label>
<label class="radio-inline"><input type="radio" name="UserForm[custtype]" value="2"> B2B</label>
<label class="radio-inline"><input type="radio" name="UserForm[custtype]" value="3"> Both</label></div>
<div class="help-block"></div>
</div>
Here I want to extract value of selected radio. I tried getting value by:
$('input:radio[name=UserForm[custtype]]:checked').val()
but no luck.
Required output : 1 or 2 or 3 based on the selection.
Please help me on this, thanks in advance.
Upvotes: 1
Views: 1778
Reputation: 4124
Your code looks fine. You have just forget the quotes surrounding the name. It should be like this:
$('input:radio[name="UserForm[custtype]"]:checked').val()
Hope it's useful!
Upvotes: 4