/    Sign up×
Community /Pin to ProfileBookmark

Changing focus of buttons depending on where the cursor is

I have a welcome page that has two forms. The two forms have two different functions on my site….here is the php code:

[code=php]
echo “<body>”;
echo “<br><br><br><br><br><br>”;
echo “<center><p style=font-size:200%><b>Auto-Trail Parts Catalogue</b></p></center>”;
echo “<center><p style=font-size:160%><i>From here you can search for parts.</i></p></center>”;
echo “<center><p style=font-size:115%><a href=’javascript: loadTop50()’>Click Here</a> to view the top 50 ordered parts</p></center>”;
echo “<br>”;
echo “<form name=’buildnumbersearch’ action=’buildnumbersearch.php’ method=post>”;
echo “<center><p><b>Build Number Search</b><br><i>Enter a build number:</i> <input type=textfield maxlength=4 name=buildnumber style=width:75px><input type=submit name=submit value=’Find’></p></center>”;
echo “</form>”;
echo “<form name=’partnumbersearch’>”;
echo “<center><p><b>General Part Search</b><br><i>Enter a part id #: </i><input type=textfield size=9 name=partnumber> <i>and/or enter a keyword:</i> <input type=textfield name=keyword> <input type=button name=find value=Find onclick=’javascript: search()’></td></tr>”;
echo “</form>”;
echo “</body>”;[/code]

what i would like to do is focus onto the relevant button when a textfield is selected so that enter can be pressed instead of clicking on the button

Should I have my buttons as submit buttons??

Do you understand what i am trying to do?

Regards

Edwardp

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 11.2005 — Hi![i]Originally posted by Edwardp [/i]

[B]Should I have my buttons as submit buttons??[/B][/QUOTE]
The button in the first form is a submit button already. Just change the button in the second form to type="submit" as well and call the function - which at present is invoked onclick of the button - onsubmit of the form (remove the onclick="blah" from the button and add onsubmit="blah" to your second form tag).

Cheers - Pit
×

Success!

Help @Edwardp spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...