473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

putting the cursor in a password field on page load

I have a page that is simply a password field. Doesn't scroll, do anything
other than accept a password, and has a submit button.

How can I automatically place the cursor in this password field when the
page loads?

I think it would be really nice to just have to type the password and hit
enter.


Jul 23 '05 #1
4 1867
"ScooterMX" <sc*****@nowhere.org> wrote in message
news:yr***************@newssvr14.news.prodigy.com. ..
I have a page that is simply a password field. Doesn't scroll, do anything other than accept a password, and has a submit button.

How can I automatically place the cursor in this password field when the
page loads?

I think it would be really nice to just have to type the password and hit
enter.


<html>
<head>
<script type="text/javascript">

function initialize() {
document.getElementById(passWord).focus();
}

</script>
</head>

<body onLoad="initialize();">
...
<input id="passWord" name="passWord" type="password" />
...
</body>
</html>

--
Dag.
Jul 23 '05 #2
Dag Sunde wrote:
[...]
function initialize() {
document.getElementById(passWord).focus();
}


Or if you want it to work:
function initialize() {
document.getElementById('passWord').focus();
}

Note use of quotes around "passWord". If you want it to also work in
older versions of IE:

function initialize() {
if (document.getElementById) {
document.getElementById('passWord').focus();
} else if (document.all) {
document.all['passWord'].focus();
}
}

--
Rob
Jul 23 '05 #3
function initialize() {
if (document.getElementById) {
document.getElementById('passWord').focus();
} else if (document.all) {
document.all['passWord'].focus();
}
}


Thanks.
Jul 23 '05 #4
RobG wrote:
Dag Sunde wrote:
[...]
function initialize() {
document.getElementById(passWord).focus();
}

Or if you want it to work:
function initialize() {
document.getElementById('passWord').focus();
}

Note use of quotes around "passWord". If you want it to also work in
older versions of IE:

function initialize() {
if (document.getElementById) {
document.getElementById('passWord').focus();
} else if (document.all) {
document.all['passWord'].focus();
}
}


And if you want it to work in any browser that supports the scripting of
forms:

document.forms['formName'].elements['elementName'].focus();

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jim Mitchell | last post by:
I have a web page that I show using show ModalDialog. The web page takes about 6 seconds to load. No matter what I try, I can not get the cursor to show a "WAIT" until the page is loaded in...
5
by: ChadDiesel | last post by:
My basic question is why does my print report button on my subform print a blank report when my cursor is on a blank entry line? Here is a more detailed explanation of my problem. I have a...
4
by: Homa | last post by:
Hi, I have a quick question. I have a webpage allow user to modify his/her information. When I generate the form, I want to pre-load the information to the TextBoxes. But for the password...
1
by: Olav Tollefsen | last post by:
I use this code to set focus to a textbox when I load a page: private void SetFocus(System.Web.UI.Control ctrl) { string s = "<SCRIPT language=\"javascript\">document.getElementById('" +...
2
by: MattB | last post by:
I have a page where a person can edit their account information and one of the things to edit is a password. I'd like to be able to pre-populate this field with something to indicate they have one...
6
by: James | last post by:
Have a textbox that's in Password mode on a user creation page. Have several dropdowns that cause a PostBack out of necessity on this page. I cannot separate them. When one of these dropdowns...
7
by: P. Adhia | last post by:
Sorry for quoting an old post and probably I am reading out of context so my concern is unfounded. But I would appreciate if I can get someone or Serge to confirm. Also unlike the question asked in...
0
by: crpietschmann | last post by:
I have a databound TextBox in a FormView control with it's TextMode set to Password. My issue is that when the page loads the password field is empty. This is causing problems of clearing out the...
21
by: tvnaidu | last post by:
This is the Java script I am using fo rlogin page, but cursor not pointing to login box, any idea how can I point cursor to login box when this page loaded?. here admin login take to control page and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.