开发者

getting multiple values from a form using ajax

hi all ive found this script and ive been amending it but im not sure how to change it so it can handle multiple values.. ive got a form with many different select options and im tryin to pass all the selected options to my ajax.php page where ive go开发者_StackOverflow中文版t a mysql select statement that uses the selected options to perform a search result. the code below works but only on the first two selected options. can anyone help?

Cheers

 $(function() {


            $("#lets_search").bind('submit',function() {
                var value = $('.option:selected').val();
                $.get('ajax.php',{value:value}, function(data){
                    $("#search_results").html(data);
                });
                return false;
            });
        });
    </script>


You just need to pull out the other values using .val() and add them to the object

     var value = $('.option:selected').val();
     var value2 = $('.text').val();
     $.get('ajax.php',{value:value,value2:value2}, function(data){
          $("#search_results").html(data);
     });


Use .each or .live

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜