13th March 2008 - 3 minutes read time
Creating a form as part of an AJAX control is a common practice, but when you include a submit button within the form the default behaviour of the form is to redirect to the destination supplied in action. To run a form using JavaScript you need to include two things.
<form action="javascript:return false;" method="post" id="analysisForm" >
In order to overwrite the normal operation of a form you will need to replace the action attribute with some JavaScript code that returns false. This is can be done in the form of come in-line JavaScript code (commonly called a bookmarklet) in the place of any URL in the action attribute of the form.
Next, in order to actually get JavaScript to intercept the form submission action an onsubmit event is added to the form tag.