SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

Onclick selection of textbox data

We can select the text inside a textarea by clicking inside the textarea. This is required when we want to give a piece of code to the visitors can copy. We will use onClick event to trigger a function and we will keep the code.

text_val.focus();
text_val.select();

Here is the demo of the script.








Click inside the textbox below
Here is the full code of the script.

<html><head><title>(Type a title for your page here)</title>

<script type="text/javascript">
function select_all()
{
var text_val=eval("document.form1.type");
text_val.focus();
text_val.select();
}
</script>

</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<form name=form1 method=post action=''''>
<textarea name=type rows=3 cols=35 onClick="select_all();">This text you can select all by clicking here </textarea>
</form>

</body>
</html>


Further readings
Hide and displaying layers through buttons
Hide and displaying layers through radio buttons
OnClick event of period button
Default value by using OnFocus event of a text box
Showing help text by using onfocus and onBlur event triggers
Text box click event removing data
Text box onBlur click event changing case
Selecting all the data of inside textarea by clicking
Counting the characters dynamically inside a textarea and setting a limit
Copying a set of textbox entered data to another area of a form
Copying data along with drop down list box selection inside a form
Managing browser status bar message onMouseOver & onMouseOut events of a link
OnMouseOver image changing over a link
 
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
JavaScript Tutorials
Popular Tutorials
Drop down list
Timer function
JavaScript Tutorials
String
Array
Date & Time
Form Validation
Event Handling
Math Functions
Loops & structure
JavaScript Forum
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.