PDA

View Full Version : submit form with button


webmarkart
11-04-2002, 09:47 PM
Yes, I've already searched the forum and all of the pertinant posts didn;t really resolve this question. I want to use an image in place of the typical sumbit and reset buttons.

Here is the code I am using:


<SCRIPT LANGUAGE="JavaScript">
<!--
function validateForm()
{
if(document.form1.SEARCH_BY.value == "")
{
alert("Please Enter a Search Term");
document.form1.SEARCH_BY.focus();
}
else
{
document.form1.submit();
}
}
//-->
</SCRIPT>

<FORM ACTION="default.asp?action=searchlist" NAME="form1">
<P><INPUT TYPE="text" NAME="SEARCH_BY" VALUE="" SIZE="18" MAXLENGTH="50">
<A HREF="javascript:validateForm()"><img src="images/go.gif" alt="" width="15" height="15" border="0"></A></P>
</FORM>


the action is default.asp?action=searchlist and on that page I am Trim Requesting the variable "SEARCH_BY". Instead of going to this page however it submits to default.asp?SEARCH_BY=test.

I've also tried <input type="image" action="submit" src="images/go.gif">

and <input type="image" action="submit" src="images/go.gif" alt="Go" name="Go" width="15" height="15">

nothing seems to work. Try the seach yourself: www.webmarkart.com/because (on the bottom right).

wap3
11-04-2002, 09:58 PM
Try the following

For submit button:

<input type="image" name="Submit" value="Submit" src="Images/submit_button.gif" width="62" height="17">

For Reset button:

<input type="image" onClick="this.form.reset(); return false" src="Images/reset_button.gif" width="62" height="17">


Hope it helps

:thumbsup:

Roy Sinclair
11-04-2002, 09:59 PM
The "Action" clause of your form is incorrect. You can't pass a GET type value that way because the FORM replaces it with it's own form fields. Any values you need to pass must be a part of the form.


<form action="default.asp" name="form1">
<input type="hidden" name="action" value="searchlist" />
<p><input type="text" name="SEARCH_BY" value="" SIZE="18" maxlength="50" />
<a href="java script:validateForm()"><img src="images/go.gif" alt="" width="15" height="15" border="0"></a></p>
</form>

webmarkart
11-04-2002, 10:07 PM
indirectly I got my question answered... I forgot method="post"! I used my exact code and added the method and it works now... Thanks