/    Sign up×
Community /Pin to ProfileBookmark

text box focus

Hi,
I have a text box in a jsp page. When user types some text and submits i retain the text in the text box and use textbox.focus() to focus the cursor in the text box when the page is reloaded (<body onload=”textbox.focus()” ) every thing works fine but the cursor positions it self before the first character but i want to focus after the last character. Example: this is the text “HTML” in text box when the page is reloaded the cursor is placed before “H” but i want to place the cursor after the “L”. Is there any solution??

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@FangMar 08.2006 — &lt;body onload="textbox.focus();textbox.value+='';"
Use the correct method to reference the text box: [I]document.forms[formName].elements[elementName].foo[/I]
Copy linkTweet thisAlerts:
@jvijaykmrauthorMar 09.2006 — Hi Fang,

Thank you for your code. It works ... great.

but what does the code do, I think it just appends empty space with the value how does it places the cursor after the last character?

thank you

Vijay
Copy linkTweet thisAlerts:
@pragyaJul 09.2008 — Thanks a tonnnnnnnnn for this code ?

Really....it was a small thing but just slipped out of my mind :rolleyes:

?
×

Success!

Help @jvijaykmr 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...