09-25-2003, 05:17 PM
I have a simple "email to a friend" form. When users get there, I want the cursor positioned in the first field of the form -- the FromName field.
Seems to me this should be simple -- what am I doing wrong here?
09-25-2003, 05:27 PM
1) do you have form tags around the field? IE don't care, virtually everyone else does.
2)<BODY onload="document.emailform.FromName.focus()"> -- a full DOM path is required
09-25-2003, 05:39 PM
Vinny: Thanks for the quick reply.
Not sure what you mean by form tags around the field. This is a ColdFusion form, so I have <CFFORM> and </CFFORM> around the form itself, and <CFINPUT> tags around each field. Is it maybe the ColdFusion aspect that's giving me trouble?
I didn't have the full DOM path, but now do as you suggested. Still OK in IE, still not OK in Netscape.
09-25-2003, 05:59 PM
Is it maybe the ColdFusion aspect that's giving me trouble?
09-25-2003, 06:00 PM
You used an IE proprietary shortcut which explains why it works in IE but not Netscape.
09-25-2003, 06:01 PM
Type "mocha" in the address bar, hit "enter", and let us know what the error message is. :)
09-25-2003, 06:11 PM
Thank you all -- maybe now we're getting somewhere?
document.forms.emailform has no properties.
What kind of properties might it be looking for?
I also tried changing my onload tag to look as Roy suggested,
but that didn't help. (didn't hurt either, which is always a good thing.)
09-25-2003, 06:15 PM
Do you have anything in the document set with a CSS 'position:absolute' (or 'relative')?
09-25-2003, 06:22 PM
Is it common practice with coldFusion to put a document inside a document?
09-25-2003, 06:26 PM
I didn't look at all the code, but if you are writing the second 'body' somewhere up top, NN4 may be trying to execute the onload before the form is written. In which case, the form has no properties.
Try putting the ''document....focus()" just before the closing body tag:
09-25-2003, 06:36 PM
OK...your HTML is, well, a mess. Two body tags, two </head> tags, scripts stuck in between head #2 & body #2...eeesh. All that needs to be fixed. And all that 'dynamic' HTML output is completely off the map, no way to build a page.
Here's the focus thing: Navigator 4 generates a Layer object every time you use CSS to set an element to position:absolute/relative. Don't ask why, it's a miserable decision made back in 1997. Since you've set your <div ID="contentmiddlenav"> to position:absolute, the form inside it is now in a stinkin' layer, which means it's essentially in another window. Great.
var Explorer4 = (document.all);
var Netscape6 = (document.getElementById);
var Netscape4 = (document.layers);
onload = function()
09-25-2003, 06:41 PM
Glad you had the patience to read all the code. Guess I should have drunk some 'mocha' :D
09-25-2003, 06:44 PM
Vinny, your latest post was right on target!
You were right not to look at all the code -- I'm including templates and other Cold Fusion stuff that makes this a messy page to look at in source view.
But I put this code
immediately after the form and the close of a series of If statements that help define who gets what kind of email. The onload tag is followed by a couple of Cold Fusion templates, then the </body> tag. It works swimmingly now.
Wanted to thank you all for this exchange. I'm new to CodingForums but will be back! Great help, and fast! Thanks again.
09-25-2003, 06:56 PM
Sorry to disappoint you, but putting that body tag inside the layer (in between the <div></div> tags) was what 'fixed' it. The onload handler then runs in the scope of the layer, not the main window. This is not the proper way to do it, but I'll leave it at that....
09-25-2003, 07:00 PM
I'll work on the mess. Am building on CF templates others have written, and I know it's not a pretty site/sight!