PDA

View Full Version : no select text script



wilfredong138
06-01-2005, 10:44 AM
In the no select text script page ,we cannot select any text but can select the text in the box that let us put it in our HTML. How is it possible? Can you teach us how to do it?

jscheuer1
06-01-2005, 09:14 PM
Put this script in the head of your page:
<script type="text/javascript">
function highlight(x){
document.forms[x].elements[0].select()
}
</script>Then, in the body, you can use this link to highlight (select) text in a text box that is the first element of a form numbered 'x' (forms are seen by javascript as numbered on each page starting with 0):
<a href="javascript:highlight(x)">Select</a>Using 0 in place of the red x, this would work on a text area in a form like this:
<form>
<textarea rows="10" cols="10">
Put the text you want highlighted here
</textarea></form>provided it is the first form on the page.