Choose 1 form to submit with multiple forms on page
I have a page with multiple forms on it. Each form as different id but same name and consist of only radio buttons. I want to perform a submit via ajax but U am having a hard time only choosing the correct form in my code. What do I need to only submit the form where the radio button is selected. I have it working fine with only one form on the page.
-
<form id="1" name="myForm"> |
|
|
|
<input type="radio" name="contract" value="0" class="custom-switch-input" checked> |
|
|
|
<input type="radio" name="contract" value="1" class="custom-switch-input" > |
|
|
|
<input type="radio" name="contract" value="2" class="custom-switch-input" > |
|
|
|
<input type="radio" name="contract" value="3" class="custom-switch-input" > |
|
|
|
|
- $(document).ready(function()
- {
-
- $(document).ajaxSuccess(function()
- {
- $("#output").fadeTo(4000, 500).slideUp(500, function(){
- $("#output").slideUp(500);
- });
-
- });
-
- $('input[type="radio"]').click(function(){
- var contract = $(this).val();
- var id = $('input[name=id]').val();
- var table = $('input[name=table]').val();
-
- $.ajax({
- url:"edit_do.php",
- method:"POST",
- data:{
- contract: contract,
- id:id,
- table:table
- },
-
-
- });
-
- });
- });
- </script>
|
|