Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<CFINCLUDE> and element.focus()

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
I had a simple javascript statement in my <BODY> tag that said
Code:
onLoad=&quot;form.element.focus();&quot;
Everything worked fine until I included a template file. Now I've lost focus on that form element. I can put the focus() function in the template's <BODY> tag, but I would have to do that for every form on my site. What's the syntax for setting focus to the form element in array [0]? That would solve my problems. Kevin
slanek@ssd.fsi.com
 
I have always used document.form_name.element_name.focus()

Simon
 
Hey all, I found it in an old college book. I used:
Code:
<SCRIPT LANGUAGE=&quot;JavaScript&quot;><!--
document.forms[0].elements[0].focus();
//--></SCRIPT>
in the template to make focus go to the first form element in all my pages. Now, this may not work for everyone. I happen to want focus to be set to the first element in all my pages, but others may not. If you change the numbers to 1 or 2 or something, focus will be set to another element.

So there it is. Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top