Click on left textarea to select and copy text
Return to tutorial on
textarea onclick selection all
JavaScript
<script type="text/javascript">
function select_all()
{
var text_val = document.getElementById('t1');
text_val.focus(); // Focus on textarea
text_val.select();// Select all text
document.execCommand("Copy");
document.getElementById('my_msg').innerHTML=" Text Copied.. <br>Paste by usnig Ctrl + V at right > textarea";
document.getElementById('t2').focus();
}
</script>
HTML
<div class='row'> <div class='col-md-3'>
<form name=form1 method=post action=''>
<textarea name=type id=t1 rows=5 cols=35 onClick="select_all();">This text you can select all by clicking here </textarea>
</form>
</div><div class='col-md-3'>
<div id=my_msg class='bg-info'>Click on left textarea to select and copy text</div>
</div><div class='col-md-3'><textarea id=t2 name=t2 rows=5 cols=35 ></textarea>
</div></div>