1

Here is a my html form ,In this form have three select dropdown and i am submitting this form using ajax on onchange. So if i select first dropdown it will display first selected dropdown value. If I select second dropdown it will display only the second selected dropdown value. But i wanted to display all selected dropdown I mean first, second and third selected dropdown value.

So my question is how to get all selected value from multiple select tag. And here ajax file file_ajax.php code

<?php 
if($_GET) 
{ 
  print_r($_GET); 
} ?>
And here is my script

$("form select").on('change', function () { 
             $.ajax({
         	  url: 'file_ajax.php',
         	  type: 'GET',
         	  data: $(this).serialize(),  
                  dataType: 'html'
                  })
               .done(function(data){
             	 $('#form-content').html(data);
             })
             .fail(function(){
                 alert('Form Submission Failed ...'); 
             });
             
         });

Please reply me thank you.

1
  • Please also add your javascript or jquery code, you're using for ajax. Commented Dec 15, 2016 at 7:37

1 Answer 1

1

You have a problem in this function

$("form select").on('change', function () {
    $.ajax({
        url: 'file_ajax.php',
        type: 'GET',
        data: $(this).serialize(),
        dataType: 'html'
    })
    .done(function(data){
        $('#form-content').html(data);
    })
    .fail(function(){
        alert('Form Submission Failed ...');
    });
});

You serialize only one select dropdown

$(this).serialize()

this means the object from which the event occurred

Sign up to request clarification or add additional context in comments.

2 Comments

Ok @Adrian Bobrowski, let me to check
Thank you @Adrian Bobrowski, I added this var dataString = $("#chkveg, #chkveg1, #chkveg2").serialize();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.