10-20-2005, 11:17 AM
My site has a simple search engine but every time I search for something, the page reloads and it really does not need to.
<INPUT TYPE="text" SIZE="20" NAME="TEXT" onClick="form.TEXT.select()">
<INPUT TYPE="submit" VALUE="search"><BR>
<INPUT TYPE="checkbox" NAME="google">google<BR>
<INPUT TYPE="checkbox" NAME="yahoo">yahoo
Any tips on how to stop the page from reloading after submitting the form so I can search again?
10-20-2005, 11:20 AM
10-20-2005, 08:38 PM
for(var i=0; i<TEXT.length; i++)
if(TEXT.charAt(i)==" ") plus+="%20";
10-21-2005, 06:08 AM
I don't know a lot about this, but is there a simple solution by adding an "onSubmit" to the form and using it to stop the page from reloading so one can search again?
10-21-2005, 02:42 PM
You could try:
* In you <form>, onSubmit="searchFunction(); return false;"
* Or in your <input type='checkbox'>, onClick="searchFunction()"
* Or in your <input type='submit'>, onClick="searchFunction(); return false;"
where searchFunction() is your custom searching function. In the first and last cases, you need to include the "return false" to prevent the form from actually submitting (and hense reloading)...
10-21-2005, 07:08 PM
Thanks a lot, the third suggestion works great; I didn't realize just adding "return false" would fix the problem so I appreciate it.
10-21-2005, 07:41 PM
Also, if you have some type of validation function, you could have that return true if you want the form to be submitted or false if you want to halt submittion. Then just onClick="return validationFunction()" in your submit button.