Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP - Using an Enter key to submit a form....

Status
Not open for further replies.

SmileyFace

Programmer
Sep 10, 2002
99
US
I would really appreciate help with this....

I have a form on a page which has an image called 'Save' to submit it. This image currently calls another function called 'fsubmit' on the page which validates the form before submitting it. I need to use the 'Enter/Return' key to subit the form. Thus I cannot use the usual form submit as it doesn't have a parameter 'action' which sends it directly to another page.

So basically I need to be able ot use the 'Enter' key to submit a form where the submit button is an image which calls another function on the same page. PLEASE HELP. If there is a way to do this without using an image thats fine too. Thanks a lot in advance. Heres how some of the code looks...

-------This is part of a VBScript-------------------------
sub fReset
window.frmHouseHold.reset
end sub

sub fSubmit
if validform then
<%if ActionToTake = &quot;I&quot; then%>
window.frmHouseHold.action = &quot;HouseHoldEdit_Action.asp?fx=I&quot;
<%else%>
window.frmHouseHold.action = &quot;HouseHoldEdit_Action.asp?fx=U&household_id=<%=HouseHoldID%>&quot;
<%end if%>
window.frmHouseHold.submit
end if
end sub
-----------------------------------------------------------

-------This is the form------------------------------------
<form id=&quot;frmHouseHold&quot; name=&quot;frmHouseHold&quot; method=&quot;post&quot;>

<table border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;>
<tr valign=&quot;middle&quot;>
<td><font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#FFFFFF&quot;><b>Address</b></font></td>
<td><input type=&quot;text&quot; name=&quot;txtAddress1&quot; size=&quot;35&quot; maxlength=&quot;35&quot; value=&quot;<%=txtaddress1%>&quot;></td>
</tr>
<tr valign=&quot;middle&quot;>
<td></td>
<td><input type=&quot;text&quot; name=&quot;txtAddress2&quot; size=&quot;35&quot; maxlength=&quot;35&quot; value=&quot;<%=txtaddress2%>&quot;></td>
</tr>
<tr valign=&quot;middle&quot;>
<td><font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#FFFFFF&quot;><b>City</b></font></td>
<td><input type=&quot;text&quot; name=&quot;txtCity&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%=txtCity%>&quot;></td>
</tr>
<tr valign=&quot;middle&quot;>
<td align=&quot;right&quot; colspan=&quot;2&quot;>

<img border=&quot;0&quot; src=&quot;../../images/btnSave.jpg&quot; onclick=&quot;fsubmit()&quot; style=&quot;cursor:hand&quot;>
<img border=&quot;0&quot; src=&quot;../../images/btnReset.jpg&quot; onclick=&quot;freset()&quot; style=&quot;cursor:hand&quot;>

</td>
</tr>
-----------------------------------------------------------
 
An <input type=submit> button should do the trick for you here.

-----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
<input name=&quot;validate&quot; type=&quot;image&quot; src=&quot;=&quot;../../images/btnSave.jpg&quot; value=&quot;Submit&quot; onclick=&quot;fsubmit()&quot; style=&quot;cursor:hand&quot;>

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Thanks Deecee. Your script seems to work. Howver I noticed if I try entering information into text boxes and hit submit it works fine but if I select something from a combo box and then hit enter it doesn't go anywhere. Wy would this happen?
 
dunno really my guess is your form might not be set up correctly..are you giving values to you combo box items?

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top