Jump to content

[SOLVED] probably really easy....


dumdumsareyum

Recommended Posts

I have a question that's probably really easy, but the only thing my javascript book has done for 8 chapters is teach me how to make every event create a popup window  :(

 

All I want to do is when the page opens have a certain form field already "in focus" and ready to be typed in so that the user does not have to click in it to start typing.  I have some ideas about onload and focus and stuff, but i'm not really sure what to do.  Thanks

Link to comment
Share on other sites

so you know how to add events when the page loads? if so, just do this

 

document.getElementById('field').focus();

 

there you go.

 

and you can be a little more complex for things like login forms. lets say you have a user field and password field, you can check the content of the userfield to see if it has any input, if not focus on it. if it does focus on the password field

Link to comment
Share on other sites

ok, I added this:

 

<body marginwidth="0" leftmargin="0"  onLoad = document.getElementByID('password').focus() >

 

but, no luck.......this part is called from an php include file, would that matter any?  I also tried getElementsByName.

 

Then I tried putting

 

<script language="JavaScript">

<!--

document.getElementbyID('password').focus();

//-->

</script>

 

in the html right after the password field.  Still no luck. What am I doing wrong?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.