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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

easy if you know, but i can't remember

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
VN
Hey there,

I am trying to create a form where there is only one text field and one button. A search form.

All i am trying to do is set the action on the button to be triggered by the 'enter' or 'return' key aswell.

Please help,

Thanks

Jez

:)
 
Is it the only form on the page? It should work by default this way. Dean Owen
 
put the html as below,

<FORM METHOD=&quot;POST&quot; ACTION=&quot;the-script-to-run&quot;>
<INPUT type=&quot;text&quot; name=&quot;t&quot;>
<INPUT type=&quot;submit&quot;>
</FORM>

Now in your script (either an ASP or CGI) read the text box value thru the variable name of t.

If you type the value and press either enter key or click the button it will call the script.
 
is it not something like tab or tabindex what u want to use?
i neither know the right attribute anymore. But i thought it was tabindex. mcvdmvs
mick@nederland.net

knows: html, JavaScript, dhtml, css, php, mysql, postgresql, xml, linux
to learn: java, c++, perl, python
 
This code is to submit an ASP form and although I'm very new to ASP, I was sure that the first 2 replies are correct.
That is either the submit button should be tied to the return by default as it is the only form (and only submit button) on the page or failing that, if the script refers to the text field by 'name', that should cause the enter key to work for submision.

As for the tab order, I did think that might be to do with it but I tried setting that and no luck (although the syntax may have been wrong).

I have found a strange IF statement in the ASP though which i am looking at the momment. I have a feeling it is stopping the default actions for some reason......
 
WOO-HOo

I have got this working now, and it was the ASP.
I should put this in the ASP forum, but since it is the solution to this i will leave it here.

The replies above are correct and work fine now that the ASP is fixed.

The ASP form is for a customised version of the search that is included with IIS 5 / Index server, and there was a line saying

if Request.Form(&quot;searchit&quot;) = &quot;Go&quot; then

this makes the submit action only true if the button named 'searchit' is pressed.
I commented out this line and it's corressponding 'end if' statement and the return key now functions, and the actual search isn't affected.

Anyone who would like the full source code please email me,

jez@smokingbear.com

And thanks again.

Oh and as for the tab order I haven't gone back to that yet as with only one text field and one button, tabbing gets you where you want to go.

Cheers

Jez

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top