I have a form with onsumbit attribute. I am calling a javascript function on the onsumbit.
I need to set some values on hidden variables before the form actually submits. That bit is done in the SaveQuery() function. I also have a link on the page which does the same action of submitting the form. I have added the onsubmit, so that the form gets submitted when some one presses the Enter key.
The problem is that when using jquery v1.4.4 library, the form seems to be submitted recursively. How do I avoid that from happening. With jquery v1.3.2, there doesn’t seem to be a problem.
The Form:
<form id="savequery" action="savedquery.aspx" method="post" onsubmit="SaveQuery(); return false;">
<input type="hidden" id="orig_q" name="orig_q" value="" />
<input type="hidden" id="isFullText" name="isFullText" value="" />
<input id="queryName" name="queryName" value="New Query" />
</form>
<table class="centerButton">
<tbody>
<tr>
<td>
<div id="proceedSave" class="butActive idProceed">
<p>
</p>
<div>
<a href="#" onclick="SaveQuery();">Proceed</a></div>
</div>
<!-- duplicate text item -->
</td>
</tr>
</tbody>
</table>
SaveQuery Function:
SaveQuery = function () {
$("#orig_q").val(document.getElementById("txtQuery").value);
$("#isFullText").val(document.getElementById("chkFulltext").checked);
$("#savequery").submit();
}
Instead of stopping the submission and triggering it, you can just let it pass though: