Use the following JS code once the page is loaded:
document.getElementById ( 'input_id' ).focus();
Obviously, 'input_id' is the value of the id attribute for the textbox.
On 4/12/06, David Elliott [EMAIL PROTECTED] wrote:
Hi all,
just an easy question probably, I wrote my first two
pages
does this code need to appear in any certain area of
the web page? i.e. body, head ??
--- Bryan Stevenson [EMAIL PROTECTED]
wrote:
coming from memorybut some JavaScript along
these lines should work:
script language=JavaScript
onLoad =
Yeah, it should go in your head.
head
script type=text/javascript
the javascript...
/script
/head
On 4/12/06, David Elliott [EMAIL PROTECTED] wrote:
does this code need to appear in any certain area of
the web page? i.e. body, head ??
--- Bryan Stevenson [EMAIL PROTECTED]
wrote:
coming
None of the suggestions work for me, but here is the
code for the entire page...remember, I am just
learning coldfusion so don't laugh yourself sick...
Dave
--- Ryan Guill [EMAIL PROTECTED] wrote:
javascript code:
window.onload =
document.myformname.myforminput.focus();
where
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01
Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
html
head
meta http-equiv=Content-Type content=text/html;
charset=iso-8859-1
titleDave's Query/title
script language=JavaScript
window.onload =
document.yardage_ticket_no.yardage_ticket_no.focus();
You need a name on your form,
cfform action=DaveActionForm.cfm name=myForm
Then put myform in the js,
document.myform.yardage_ticket_no.focus()
On 4/12/06, David Elliott [EMAIL PROTECTED] wrote:
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01
Transitional//EN
document.yardage_ticket_no.yardage_ticket_no.focus();
You DO NOT have a form named yardage_ticket_no so of course it won't work ;-)
document.formName.fieldName.focus();
change your cfform tag to look like so:
cfform action=DaveActionForm.cfm name=yardageForm
and use this:
still doesn't workmust be missing something else.
I've tried it with the semi colon without on that
line and have the same resultshere is the code
again
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01
Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
html
head
meta
make it cfinput type=text name=yardage_ticket_no
id=yardage_ticket_no / then.
On 4/12/06, David Elliott [EMAIL PROTECTED] wrote:
still doesn't workmust be missing something else.
I've tried it with the semi colon without on that
line and have the same resultshere is the code
Dave -
Try this:
script language=JavaScript
window.onload = function() {
document.myform.yardage_ticket_no.focus()
};
/script
I can't swear to this for built-in functions like focus(), but if I
were calling a custom function, I would need to leave the parentheses
off of your original
window.onload =
document.myform.yardage_ticket_no.focus()
add a semi-colon to the end
document.myform.yardage_ticket_no.focus();
Also try the code I sent you ;-)
What browser are you tesring with BTWthis can effect things
Bryan Stevenson B.Comm.
VP Director of E-Commerce Development
The line break after window.onload =
could cause a problem (maybe?)
On 4/12/06, Bryan Stevenson [EMAIL PROTECTED] wrote:
window.onload =
document.myform.yardage_ticket_no.focus()
add a semi-colon to the end
document.myform.yardage_ticket_no.focus();
Also try the code I sent you ;-)
The browser is IE Mozilla; makes no difference.
I've tried all your suggestions but the input box
never gets the focus. Perhaps it cannot be done.
Perhaps I'll come across something more suitable in my
book.
Dave
~|
Message:
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
html
head
titleUntitled/title
/head
body onload=JavaScript:document.myForm.myField.focus();
form name=myForm action= method=post
textarea name=myField/textarea
/form
/body
/html
this works fine in IE and Firefox
hth
Charlie
Perhaps CFFORM is messing with the form name?
try a normal form tag and see if that helps
Bryan Stevenson B.Comm.
VP Director of E-Commerce Development
Electric Edge Systems Group Inc.
phone: 250.480.0642
fax: 250.480.1264
cell: 250.920.8830
e-mail: [EMAIL PROTECTED]
web:
[EMAIL PROTECTED]
To: CF-Talk cf-talk@houseoffusion.com
Sent: Wednesday, April 12, 2006 2:30 PM
Subject: Re: input box focus
Perhaps CFFORM is messing with the form name?
try a normal form tag and see if that helps
Bryan Stevenson B.Comm.
VP Director of E-Commerce Development
Electric Edge
To: CF-Talk
Subject: Re: input box focus
The browser is IE Mozilla; makes no difference.
I've tried all your suggestions but the input box
never gets the focus. Perhaps it cannot be done.
Perhaps I'll come across something more suitable in my
book.
Dave
compliance.
I ended up putting JavaScript at the bottom of the page (just before the
closing BODY tag) to put the focus where I wanted it.
-Original Message-
From: Bryan Stevenson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 12, 2006 2:31 PM
To: CF-Talk
Subject: Re: input box focus
Perhaps
: Wednesday, April 12, 2006 12:33 PM
To: CF-Talk
Subject: Re: input box focus
Just tested my code with cfform instead of form and still functions as
desired.
Charles Hanlon
Senior Web Applications Developer
Food Service Enablers, Inc.
www.fsenablers.com
The People. The Platform. The Products.
Make
or something.
-Original Message-
From: Charlie Hanlon
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 12, 2006 12:33 PM
To: CF-Talk
Subject: Re: input box focus
Just tested my code with cfform instead of form
and still functions as
desired.
Charles Hanlon
Senior Web
I'd recommend using the getElementById over the formname.fieldname.focus().
And JS is parsed as it's read, for the most part, so simply putting
scriptdocument.getElementById('fieldIDGoesHere').focus()/script
AFTER the field should work. The bottom might be safer, and window.onload
is swell if
21 matches
Mail list logo