|
Post by votan on Sept 4, 2008 16:08:58 GMT -5
How can I make sure, that when I hit the return key, the "submit" button gets used instead of the "refresh" button? The following is just an example....[login] cls print "username : "; textbox #username, username$ html "<br>" print "password : "; textbox #userpassword, userpassword$ html "<br>" button #submit, "Refresh", [login] button #submit, "Submit", [end] wait
[end] print "Done!" end When I hit return, while the cursor is in any of the two text fields, the "refresh" gets invoked. But I need to make sure that "submit" gets invoked instead. I know that I could just make the "submit" button the first button, as hitting return obviosly always uses the first button available... but that wouldn't be a nice solution. Guess someone of you knows how to do that?
|
|
|
Post by StefanPendl on Sept 5, 2008 1:55:30 GMT -5
Check the scripting board, which has a set-focus function posted recently. Besides, I would not use the same handle for both buttons
|
|
|
Post by votan on Sept 5, 2008 7:39:13 GMT -5
Already tried that set-focus script before, but it does not work for me..... guess I'm just doing something wrong!? Here is how I did it (using IE 7)[login] cls print "username : "; textbox #username, username$ html "<br>" print "password : "; textbox #userpassword, userpassword$ html "<br>" button #refresh, "Refresh", [login] button #submit, "Submit", [end] call setButtonFocus "#submit" wait
sub setButtonFocus id$ html "<script type='text/javascript'>document.getElementById('" + id$ + "').focus()</script>" end sub
[end] print "Done!" end Upon hitting the return key, it still uses the first button available, so in this example it still invokes the refresh instead of submit.
|
|
|
Post by carlgundel on Sept 5, 2008 13:46:24 GMT -5
Doesn't work for me either using IE6. :-( -Carl Already tried that set-focus script before, but it does not work for me..... guess I'm just doing something wrong!? Here is how I did it [login] cls print "username : "; textbox #username, username$ html "<br>" print "password : "; textbox #userpassword, userpassword$ html "<br>" button #refresh, "Refresh", [login] button #submit, "Submit", [end] call setButtonFocus "#submit" wait
sub setButtonFocus id$ html "<script type='text/javascript'>document.getElementById('" + id$ + "').focus()</script>" end sub
[end] print "Done!" end Upon hitting the return key, it still uses the first button available, so in this example it still invokes the refresh instead of submit.
|
|
|
Post by David den Haring on Sept 5, 2008 17:23:06 GMT -5
I originally submitted that function for focusing on links. I modified your program to use links instead of buttons and it does work when running the program "full screen".
I can't try it with buttons because build 2.33g doesn't support buttons. What version are you using? Does the following code work with your version?
BTW, I tried this snippet with Firefox 3.0.1 and IE7.
[login] cls print "username : "; textbox #username, username$ html "<br>" print "password : "; textbox #userpassword, userpassword$ html "<br>" link #refresh, "Refresh", [login] print " "; link #submit, "Submit", [end] call setButtonFocus "#submit" wait
sub setButtonFocus id$ html "<script type='text/javascript'>document.getElementById('" + id$ + "').focus()</script>" end sub
[end] print "Done!" end
|
|