How to know, which form was clicked
Hi
I'm quite new to this jQuery and I really love it, but I just can't get to solve this little problem.
I have a page with several forms. Each form has a checkbox and some Id's behind it.
I can click on a checkbox, and it triggers the submit and save in a DB and returns an Ok. This works fine. But I simply cannot find out, how to place the Ok next to the checkbox I clicked. How do I know, which form was clicked on?
Here's the code so far:
<script language="JavaScript" type="text/javascript" src="/includes/jquery.js"></script>
<script language="JavaScript" type="text/javascript" src="/includes/jquery.form.js"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function(){
$("input").click(function(){
//$(this.form).ajaxSubmit();
var cnt = $("#cnt").val();
var trg = "#output" + cnt;
var fdo = "#SBAppl" + cnt;
$(this.form).ajaxSubmit({
target: trg
});
$(fdo).fadeOut(500);
});
});
</script>
<div id="SBAppl0">
<form method="POST" action="/MXX/SaveAppl.asp" id="0">
<input type="checkbox" name="fApplicable" value="1">
<input type="hidden" name="fSerial_Number" value="9167">
<input type="hidden" name="fSBID" value="443">
<input type="hidden" id="cnt" value="0">
</form>
</div>
<div id="output0"></div>
<div id="SBAppl1">
<form method="POST" action="/MXX/SaveAppl.asp" id="1">
<input type="checkbox" name="fApplicable" value="1">
<input type="hidden" name="fSerial_Number" value="5709">
<input type="hidden" name="fSBID" value="443">
<input type="hidden" id="cnt" value="1">
</form>
</div>
<div id="output1"></div>
etc...
Now I've tried to get the ID of the form using this line var cnt = $("#cnt").val(); but I always get the value 0 (probably from the first form). How do I tell it to use the value of the form that is clicked?
Any help highly appreciated.