Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1192 How can I select/highlight the text in a textfield using JavaScript?

You are here: irt.org | FAQ | JavaScript | Form | 11 | Q1192 [ previous next ]

Try:

<form>
<input type="text" value="1234567890" name="myText">
<input type="button" value="select" onFocus="this.form.myText.select()" onClick="this.form.myText.select()">
</form>

or:

<form name="myForm">
<input type="text" value="1234567890" name="myText">
</form>

<script language="JavaScript"><!--
document.myForm.myText.select();
//--></script>

Feedback on 'Q1192 How can I select/highlight the text in a textfield using JavaScript?'

©2018 Martin Webb