I have 2 forms with different ids, in javasciprt function i m going to get form id in variable name, but in name variable only first forms id is going, not going form 2 id my code is. HTML CODE:
<form name="form" id="filterMemberByFamNum" class="form-horizontal" role="form">
<div class="form-group">
<label>Family Number</label> <input type="text" name="familyNumber" placeholder="Family Number" class="form-control">
</div>
<button type="button" class="btn btn-primary" onclick="filterMembers();return false;">Submit</button>
</form>
<form name="form" id="filterMemberByMemName" class="form-horizontal" role="form">
<div class="form-group">
<label>Member Name</label> <input type="text" name="member" placeholder="Member Name" class="form-control">
</div>
<button type="button" class="btn btn-primary" onclick="filterMembers();return false;">Submit</button>
</form>
and JS is
function filterMembers(){
//alert("Submitted");
var str = $("form").serialize();
var name = $(this.form).attr('id');
console.log(name);
$.post("model/handler.php?name="+name+"&op=formSubmit",
{
'data':str
},function(data){
$('#members').html(data);
},"json");
return false;
}
Any time output result in console tab is "filterMemberByFamNum" infact i m submitting "filterMemberByMemName" form. Please help me.
Aucun commentaire:
Enregistrer un commentaire