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
https://forums.phpfreaks.com/topic/72111-solved-probably-really-easy/
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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.