/    Sign up×
Community /Pin to ProfileBookmark

Hightlight text box contents onclick

HI, I was wondering if its possible to highlight a text box contents when the user clicks on it, thanks!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@LeeUApr 05.2006 — From [URL=http://javascript.internet.com/forms/select-and-auto-copy.html]JavaScript Source[/URL]

[CODE]
<script type="text/javascript">
<!--
function copyit(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")
//-->
</script>
[/CODE]


[CODE]
<form name="it">
<div align="center">
<input onclick="copyit('it.select1')" type="button" value="Press to Copy the Text" name="cpy">
<p>
<textarea name="select1" rows="3" cols="25">
If this is highlighted, then it has been copied.
</textarea>
</div>
</form>
[/CODE]


This doesn't work in FireFox, though.
Copy linkTweet thisAlerts:
@idnauthorApr 05.2006 — Thanks, this works great!
×

Success!

Help @idn 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,
)...