Click to See Complete Forum and Search --> : form submit causes page to reload


webtekie
08-19-2003, 02:13 PM
Hi guys,

Busy day today, third post so far.
In my form I used to have a button to submit the form. Now I've changed it to an image and it causes my page to reload. Any suggestions?

<script>
function checkField(){
if(document.searchMenu.searchStr.value == ""){
alert('Please enter menu to search for!');
return 0;
}
str = document.searchMenu.searchStr.value;
document.all.helpiframe.src="smm3.jsp?searchStr=" + str;
showHide('passwordLayer','visible');
}
</script>

<form method="POST" name="searchMenu" onSubmit="checkField()">

<input type="image"
src="searchButton.gif"
valign="bottom"
font face="arial"
size="10">

thanks,
webtekie

pyro
08-19-2003, 02:25 PM
Try changing your onsubmit tag to look like this:

onsubmit="checkField(); return false;"
or
onsubmit="return checkField()"
and add return false to the bottom of your checkField function.

webtekie
08-19-2003, 02:43 PM
thanks pyro, that did it.

pyro
08-19-2003, 03:32 PM
You're welcome... :)