Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 11 | Q1192 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.