Small script change, need help

Discussion in 'Programming' started by Site Owner, Jul 29, 2007.

  1. #1
    Site Owner, Jul 29, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <title>Interactive Textarea</title>
      
     <script type="text/javascript">
    
    function settext(area)
    {
    	var form = document.forms[0];
    	var text = form.inputtext1.value;
    	
    	if (text && area == 'ad1' || area == 'ad2')
    	{
    		document.getElementById(area).value += '· ' + text + '\n';
    	}
    }
    
    function rem(obj) {
    var txt = document.getElementById(obj).value;
    if (!txt) return;
    var n = txt.lastIndexOf('·');
    document.getElementById(obj).value = txt.substr(0,n);
    }
    
    </script>
    </head>
    <body>
    <form>
    <table style="text-align: left; width: 100px;" border="0" cellpadding="0" cellspacing="2">
      <tbody>
        <tr>
          <td colSpan="2"><input size="30" name="inputtext1" id="inputtext1" value=""> Add to... 
          <select onchange="settext(this.value);" name="area" id="area">
          	<option selected="selected">-------</option>
            <option value="ad1">Textarea One</option>
            <option value="ad2">Textarea Two</option>
          </select>
    
          </td>
    </tr>
        <tr>
          <td>Textarea One<br><textarea rows="7" id="ad1" name="ad1" cols="22" readonly style="overflow: auto;"></textarea><div style="text-align: right;"><input name="remove" id="remove" value="Remove" onclick="rem('textarea1')" type="button"></div>
          </td><td>Textarea Two<br><textarea rows="7" id="ad2" name="ad2" cols="22" readonly style="overflow: auto;"></textarea><div style="text-align: right;"><input name="remove" id="remove" value="Remove" onclick="rem('textarea2')" type="button"></div></td>
        </tr>
      </tbody>
    
    </table>
    </form>
    <br>
    <!-- --><script type="text/javascript" src="/i.js"></script><script type="text/javascript">if(typeof(urchinTracker)=='function'){_uacct="UA-230305-2";_udn="freewebs.com";urchinTracker();}</script></body>
    </html>
    
    HTML:
     
    nico_swd, Jul 30, 2007 IP