Home > DeveloperSection > Forums > all text Selection in HTML textbox using javascript
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    December-06-2012 12:34 AM

 JavaScript JavaScript 

 1 Reply(s)
 1341  View(s)
Rate this:

I'm creating an application in HTML and I want to select all text in webpage textbox using JavaScript.

Vijay Shukla

Total Post:100

Posted on    December-06-2012 8:08 AM

that code will help you for solving your problem.

<script type="text/javascript">
function allSelection(val, id) {
        document.getElementById(id).value = val.replace('$', '');
        val = document.getElementById(id).value;
        var ctrl = document.getElementById(id);
        pos = ctrl.value.length;
        ctrl.setSelectionRange(0, pos);
<input type=='text' id='t1' value="AllSelection" onclick='allSelection(value, id)'/>

Don't want to miss updates? Please click the below button!

Follow MindStick