When I press the submit button I need to find out the form id and pass input values with post method via ajax. Can I put the form
inside the tr
tag? How can I do that?
Here is my code:
$("button").click(function(e) {
e.preventDefault();
alert("hello");
var formid = $(this).closest("form[id]").attr('id');;
alert(formid) });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<form id='idForm'>
<td><input type='input' value='12345' name='data1'></td>
<td><input type='input' value='12345' name='data2'></td>
<td><button type='submit' form='idForm'>Send</button></td>
</form>
</tr>
</table>
But when I try to check result inside Alert()
it displays undefined.