---
title: "all text Selection in HTML textbox using javascript"  
description: "all text Selection in HTML textbox using javascript"  
author: "Anonymous User"  
published: 2012-12-06  
updated: 2012-12-06  
canonical: https://www.mindstick.com/forum/484/all-text-selection-in-html-textbox-using-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# all text Selection in HTML textbox using javascript

I'm creating an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) in [HTML](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) and I want to [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) all [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) in webpage [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) using JavaScript.

## Replies

### Reply by Vijay Shukla

that code will help you for solving your problem.

```
<html>
<head>
<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);
    }
</script>
</head>
<body>
<input type=='text' id='t1' value="AllSelection" onclick='allSelection(value, id)'/>
</body>
</html>
```


---

Original Source: https://www.mindstick.com/forum/484/all-text-selection-in-html-textbox-using-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
