how to POST radio button values through jquery

前端 未结 3 1640
你的背包
你的背包 2021-01-06 19:41

i have this example code:

 while ($row = mysql_fetch_object($result1)) {                  
                    echo \'

        
相关标签:
3条回答
  • 2021-01-06 20:06

    If there is no radio button selected the radio button will not be added to the serialized string. In this case we can make a workaround by adding another one exactly like the following:

    <input type="radio" name="vote" value="" checked style="display:none;">
    
    0 讨论(0)
  • 2021-01-06 20:09

    $("[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){
      });
    });
    
    0 讨论(0)
  • 2021-01-06 20:14

    Jquery serialize is the best way to do this kind of things: http://docs.jquery.com/Ajax/serialize

    $("#submit_js").click(function() {
        $.post(
        "user_submit.php", 
        $("form").serialize(), 
        function(data){
        });
    });
    
    0 讨论(0)
提交回复
热议问题