Lets suppose you have text inside a div tag or input text field and you wish to select all the content on clicking inside it, then here is what you should do:
Textarea:
<textarea onclick="SelectAll('txtarea');" id="txtarea" rows="3" name="type">
Select all the content by clicking on it.
</textarea>
Input TextBox:
<input type="text" value="This text you can select all" onclick="SelectAll('txtfld');" id="txtfld" style="width: 200px;"/>
Here is the JavaScript function that is called above:
<script type="text/javascript">
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>
July 6, 2012 at 6:16 am
Awesome job over again! Thanks:)