Reputation: 1847
I am having a bit of trouble figuring out how to pass the selected radio button value thru JQUERY and ultimately to php.
The following is the html markup:
<li class="gchoice_1_14_0">
<input name="donation[]" type="radio" value="25" id="donation" tabindex="14">
<label for="choice_1_14_0" id="label_1_14_0">$25</label>
</li>
<li class="gchoice_1_14_1">
<input name="donation[]" type="radio" value="50" id="donation" tabindex="15">
<label for="choice_1_14_1" id="label_1_14_1">$50</label>
</li>
<li class="gchoice_1_14_2">
<input name="donation[]" type="radio" value="100" id="donation" tabindex="16">
<label for="choice_1_14_2" id="label_1_14_2">$100</label>
</li>
<li class="gchoice_1_14_3">
<input name="donation[]" type="radio" value="350" id="donation" tabindex="17">
<label for="choice_1_14_3" id="label_1_14_3">$350 - Guardian Angel Sponsorship – a donation at this level provides interview and follow-up services for one child</label>
</li>
<li class="gchoice_1_14_4">
<input name="donationother" type="radio" value="other_amount" id="donation" tabindex="18" onfocus="jQuery(this).next('input').focus();">
<input id="donation_other" name="donation_other" type="text" value="" onfocus="jQuery(this).prev("input").attr("checked", true); if(jQuery(this).val() == "Other") { jQuery(this).val(""); }" onblur="if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("Other"); }" tabindex="18">
</li>
Then I am attempting to pass the data thru jquery so it can be caught via php. This is my present jquery markup:
post_data = {
'user_name' : $('input[name=full_name]').val(),
'user_email' : $('input[name=email]').val(),
'address' : $('input[name=address]').val(),
'address2' : $('input[name=address2]').val(),
'city' : $('input[name=city]').val(),
'state' : $('input[name=state]').val(),
'zip' : $('input[name=zip]').val(),
'ccnum' : $('input[name=ccnum]').val(),
'expmonth' : $('select[name=expmonth]').val(),
'expyear' : $('select[name=expyear]').val(),
'cardname' : $('input[name=cardname]').val(),
'ccvcode' : $('input[name=ccvcode]').val(),
'donation' : $('input[name=donation]').val(),
'donation_other' : $('input[name=donation_other]').val(),
'phone_number' : $('input[name=phone2]').val(),
'subject' : $('select[name=subject]').val(),
'msg' : $('textarea[name=message]').val()
};
When I review the passing in Chrome's developer tools, the donation field/s are not being passed at all.
Could someone explain what I am missing with this? I have tried various ways of passing the donation value, but to no avail.
Thank you!
Upvotes: 0
Views: 833
Reputation: 1847
For those who research and come across this post, the proper answer to my question is to detect the value that has been checked by doing this:
'donation' : $('input[name=donation]:checked').val(),
Upvotes: 1