Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  194] [ 2]  / answers: 1 / hits: 18291  / 15 Years ago, tue, january 19, 2010, 12:00:00

i have this example code:



 while ($row = mysql_fetch_object($result1)) {                  
echo '<input type=radio name=vote value='.$row->avalue.'/>&nbsp;';
echo '<label >'.$row->atitle.'</label><br>';
}


this displays 4 radio buttons alongwith their labels.
now I am using the following jquery function to POST.



$(#submit_js).click(function() {
$.post(
user_submit.php,
{//how to POST data?},
function(data){
});
});


I want to post the value associated with the radio button. but how do i select the value?
how do i determine what radio button is selected and POST it?


More From » jquery

 Answers
72

$([name='vote']:checked).val() will get you the value of the selected radio button.



$(#submit_js).click(function() {
$.post(
user_submit.php,
{vote: $([name='vote']:checked).val()},
function(data){
});
});

[#97794] Friday, January 15, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dajah

Total Points: 208
Total Questions: 97
Total Answers: 87

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;