a1ias Posted June 9, 2006 Share Posted June 9, 2006 Hi pplThis is not particularly php specific I imagine but does play a major part in any php driven form script so the information will be very useful.I basically have a form on a page - in this instance a login form that asks for username and password.Below the forms are 2 Submit buttons, a 'Lost Password' on the left and a 'Login' on the right as follows:<td><input type="submit" name="lostpass" value="Lost Password"></td><td><input type="submit" name="login" value="Login"></td>By default, as soon as an entry is made in one of the fields, the focus appears on the 'Lost Password' button, no doubt as it is the first button that the code comes to. The problem being that for the lazy page users who enter their username/password then hit enter instead of actually clicking on a button, they are taken to the 'lostpass' script.Is there a way to apply the focus to the 'Login' button by default without changing the actual orientation [i](that's my daily "Lost" reference covered")[/i] of the buttons on the page.many thanks in advance for your assistancea1ias Quote Link to comment https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/ Share on other sites More sharing options...
kenrbnsn Posted June 9, 2006 Share Posted June 9, 2006 Since PHP runs on the server and has no clue as to the presentation of the form to the user, this needs to be done client-side. It's usually done via Javascript.Moving this to the Javascript forumKen Quote Link to comment https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/#findComment-43594 Share on other sites More sharing options...
nogray Posted June 9, 2006 Share Posted June 9, 2006 You can float the login button to the right and place it first.[code]<form><table><tr><td>Username:</td><td><input type="text" /></td></tr><tr><td colspan="2"><input type="submit" name="login" value="Login" style="float:right;"><input type="submit" name="lostpass" value="Lost Password"></td></tr></table></form>[/code]Make sure the table is big enough to fit both buttons. Quote Link to comment https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/#findComment-43733 Share on other sites More sharing options...
king arthur Posted June 9, 2006 Share Posted June 9, 2006 [code]<td><input type="submit" name="lostpass" value="Lost Password" tabindex="2"></td><td><input type="submit" name="login" value="Login" tabindex="1"></td>[/code]Job's a goodun :) Quote Link to comment https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/#findComment-43860 Share on other sites More sharing options...
a1ias Posted June 10, 2006 Author Share Posted June 10, 2006 Thanks for the responses guys, I'll play around and let you know the result as soon as my server is back up :/I did actually try the tabindex, but I think that it quite literally works only in conjunction with tabbing between buttons.However, I'll see what happens later :) Quote Link to comment https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/#findComment-43972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.