/    Sign up×
Community /Pin to ProfileBookmark

2 Things, I was wondering when a page loads, how do I make a certain text box have the focus.

Also is there a thing I can do, to turn the textbox yellow when it has focus, and regular color when it is off focus?

Thanks,

DJSM

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@pollyApr 21.2005 — 1) <body onload="[B]textbox name[/B].focus();"

2) perhaps you can make a css attribute for the background color of the selected text box
Copy linkTweet thisAlerts:
@scragarApr 21.2005 — <style>

<!--

input.focused{ background-color: yellow; }

input.blured{ background-color: white; }

-->

</style>

<input type="text" onfocus="this.class='focused';" onblur="this.class='blured';" name=txt1 value="" />
Copy linkTweet thisAlerts:
@comptech520authorApr 21.2005 — When you say this class, what do you mean?

Is that because the class in put on the webpage compared to a CSS?

Thanks,

S
Copy linkTweet thisAlerts:
@comptech520authorApr 21.2005 — I tried <body onload="uid.focus();">

it says the "uid" is not defined.

This is what I have to define it:

<input class="form" type="text" name="uid" size="27">
Copy linkTweet thisAlerts:
@pollyApr 21.2005 — try:

onload="form.uid.focus();" >

or maybe

onload="document.form.uid.focus();" >
Copy linkTweet thisAlerts:
@comptech520authorApr 21.2005 — It didn't know what onload="document.form.uid.focus();" > was, and when I used the onload="form.uid.focus();" > it said that form was undefined still.


Thanks,

S
Copy linkTweet thisAlerts:
@pollyApr 21.2005 — <body onLoad="document.[formname].[inputname].focus();">

if it's a simple text box..have you tried using a simple HTML attribute tabindex?
Copy linkTweet thisAlerts:
@pollyApr 21.2005 — may help..

[URL=http://www.htmlcodetutorial.com/forms/index_famsupp_97.html]http://www.htmlcodetutorial.com/forms/index_famsupp_97.html[/URL]
Copy linkTweet thisAlerts:
@comptech520authorApr 21.2005 — Thanks polly. I think that will do it ?
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...