Selecting all texts in text area on a single click?

Discussion in 'JavaScript' started by vbwiz, Dec 4, 2006.

  1. #1
    How do I do this without the function in the <head> section as showed on this page? http://www.plus2net.com/javascript_tutorial/textarea-onclick.php

    I can't use what that tutorial has because I'm using smarty templates and in the head section of my header there's the following.

    	 <!--!!!!!!!!!!!!!!!!!!!!!!!! LIBRARY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-->
    	<script src="{$baseurl}/ajax/cpaint2.inc.js" type="text/javascript"></script>
    	<script src="{$baseurl}/js/myjavascriptfx.js" type="text/javascript"></script>
    	<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
    
    	<!--!!!!!!!!!!!!!!!!!!!!!!!!! Processing SCRIPT !!!!!!!!!!!!!!!!!!!-->
    	<script language=JavaScript src={$baseurl}/js/indexonly.js></script>
    	<script language=JavaScript src={$baseurl}/js/myjavascriptajax.js></script>
    	<script language=JavaScript src={$baseurl}/js/myjavascript.js></script>
    	<link href="{$baseurl}/css/style.css" rel="stylesheet" type="text/css">
    	<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->	
    
    PHP:
    Where do I put the function?
     
    vbwiz, Dec 4, 2006 IP
  2. vbwiz

    vbwiz Peon

    Messages:
    184
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I figured it out, add
     
    vbwiz, Dec 4, 2006 IP
  3. vbwiz

    vbwiz Peon

    Messages:
    184
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nope, where do I put the function?
     
    vbwiz, Dec 4, 2006 IP
  4. venom

    venom Guest

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You could just copy the function into one of the existing javascripts that is in your header template.

    Just copy this code in there
    
    function select_all()
    {
    var text_val=eval("document.form1.type");
    text_val.focus();
    text_val.select();
    }
    
    Code (markup):
    Then you should be able to use onClick="select_all();" in your textarea.
     
    venom, Dec 4, 2006 IP
  5. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #5
    here an example

    
    <input title="enter your email here" type=text name=email value="email@address.com" onclick=this.select();>
    
    Code (markup):
     
    klown, Dec 4, 2006 IP