mardi 6 décembre 2016

Combine Checkbox value with Selection Option value in form

I have a form that has a list of checkboxes and selection option. It's basically an order form. When a customer clicks on a checkbox I'd like the value of the Select Option as well as the Checkbox's value to be sent with the form.

I really don't know AJAX. I'm using a script I found to get all the data to a php file. What do I need to add to the jquery to make the option and checkbox value of all the checked items combine as one variable?

<table>
     <tr>
         <td>
           <select name="qty" id="qty">
             <option value="1">1</option>
           </select>
        </td>
    </tr>
    <tr>
        <td>       
        <input id="Part1_1" name="Part[]" type="checkbox" value="Part name here">
        </td>
    </tr>
</table>

<script>
    $(document).ready(function(){
    $("#contact-form").on("submit",function(e){
      e.preventDefault(); 
          var sendData = $( this ).serialize();
          $.ajax({
              type: "POST",
              url: "orderform.php",
              data: sendData,
              success: function(data){
                  $(".response_msg").text(data);
                  $(".response_msg").slideDown();                     
              }           
          });

    });
    });
    </script>

Aucun commentaire:

Enregistrer un commentaire