Click to See Complete Forum and Search --> : Focusing problem with multiple buttons.


shu745
04-25-2003, 12:39 PM
Hey everyone I have a real simple (it seems) situation. I have my page which has a couple forms on it each having their own submit buttons.

please see my test page here:
http://www16.brinkster.com/shu745/shop/index.asp

my problem is with the search feature. the search form simply consists of the search field and search button. the thing is that it works fine if you enter a value in the search field and click the search button but if you enter a value in the search field and just hit 'enter' on the keyboard, it doesn't detect that you have clicked the search button.

you can see that the page submits but for some reason it is not submitting using the search button....very confusing! maybe since i have other buttons on my page, it doesn't know which to use...? i'm not sure.

is there a way i can focus on the search button when i focus in the search field? i thought that is how it worked...? i tried using:
<form name="frmsearch" method=...etc....>
<input type="text" name="searchfield" onFocus"this.document.frmsearch.searchbutton.focus();">
<input type="submit" name="searchbutton" value="search">
</form>

but that doesn't let you type anything in the search field obviously...hehe... then i tried using onChange but that only works if you enter a value in the searchfield then mouse click outside of the field then hit 'enter' on keyboard...

is there a way i can get this to work?

any help is appreciated...

thanx in advance...
-Shu

Jona
04-25-2003, 12:48 PM
Try it again--with an = sign after onFocus

shu745
04-25-2003, 12:51 PM
that's not really the problem..... that isn't the exact code i have on my page i just wanted to give oyu an idea of what i tried

thanx...

-Shu

Jona
04-25-2003, 01:01 PM
Just wondering. ;)

But I don't quite understand your problem. You can only focus on one element at a time. Not two. Why would you want to do this, anyways?

shu745
04-25-2003, 01:13 PM
basically all i want to do is have the user enter the search criteria in and be able to mouse click the search button or hit 'enter' on the keyboard to preform search.

my problem is when the user enters their criteria in and hits 'enter' on keyboard my search is not preformed. i am pretty sure it happens cuz i have multiple buttons on my page and it does not know which button to associate 'enter' with.....simple..hehe

regards,
Shu

Jona
04-25-2003, 01:17 PM
Put it in a form. Have only the search box and submit button in the form (name it, "search_form" or something).

bluepixie
07-23-2003, 10:20 AM
I have the problem where the form doesn't automatically submit when I type enter because there is more than one field in the form. I have read that more than one field in a form removes the default of enter or return submitting. How can I get around this? I have tried to capture the ascii code of the keystroke and use that to submit but to no avail. Below is code currently working but without my problem fixed.

Here is my last field:

<html:password property="password" size="40" maxlength="40" tabindex="2"/>

and here is my button code:

<html:button onclick="handleButton('SUBMIT');" property="SUBMIT" tabindex="3"><bean:message key="logon.button.logIn"/></html:button>

is there a way to arrange the form to somehow bring the default back without getting capturing keystrokes?:confused

bluepixie
07-23-2003, 10:22 AM
note: smileys not intentional. The code with the smiley should be:

<html:password property="password" size="40" maxlength="40" tabindex="2"/>

darn laptops.....

bluepixie
07-23-2003, 10:23 AM
again with smileys turned off:

<html:password property="password" size="40" maxlength="40" tabindex="2"/>