I'm trying to set focus on the initial form field when the User enters the page. I'd also like to know, in case of an error, how to set focus on the error field.
Can anyone help?
Thanks![]()
I'm trying to set focus on the initial form field when the User enters the page. I'd also like to know, in case of an error, how to set focus on the error field.
Can anyone help?
Thanks![]()
<body onload="document.forms[0].elements[0].focus();">
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Thanks so very much! I've had open heart surgery and one of the side effects of the heart/lung machine is that parts of memory disappear - forever. This was one of those items. I really appreciate your help!!!
Am assuming, in case of error, that one would canabalize the ONLOAD code and use the apppropriate index, right?
Well... that's probably one of the most extreme reasons for lack of Javascript knowledge I've ever seen
Yes indeed... the code I used was "the first element of the first form on the page." You can change them to reflect your element, or assign it an ID and access it with document.getElementById('id').
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
The forms and elements collections work just as well with id attributes as they do with indices and name attributes, and are better supported than the getElementById method.Originally Posted by Twey
Mike
So, better to use the former than the latter. However, if you add a new form or element before the initial element, you will need to adjust the indices.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
You wrote:
"Well... that's probably one of the most extreme reasons for lack of Javascript knowledge I've ever seen " is rather an unkind thing to say. It isn't lack of knowledge,sir. I've taught this stuff at the graduate level for a many years
Talk to any cardiologist and they'll tell you the same thing: open heart surgery using a heart/lung machine selectively destroys parts of memory. Forever. No one knows why.
Perhaps I'm just tired right now but I think an apology would not be out of place here. If I knew to whom this kind of thing should be reported, that would be my next step. It must be very nice to live in your particular world.
I'm sorry, it wasn't intended to be insulting. Perhaps "memory" is a better word than "knowledge" in the circumstance. If you feel it should be reported, ddadmin is the one to go to.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I think this is just a misunderstanding. From how I saw it, Twey was being playful when he made that comment, with no intent to insult at all. Adding a smilie face at the end usually is a sign of that.![]()
OK, then. Over and done with, I guess.
Bookmarks