how to add tags into an input field?

Discussion in 'JavaScript' started by falcondriver, Nov 25, 2006.

  1. #1
    i have no idea about js, so guess thats an easy one:
    on my form is a textarea "tags" and some links below. now i want this linktext in my formfield if someone clicks on it - as seen on del.icio.us on this "submit a site " page. so here is what i got so far:

    function addtag(tagname) {
    	document.submitform.tags.value = document.submitform.tags.value + tagname;
    }	
    Code (markup):
    <form action="submit.php" method="POST" id="submitform">
    			<table style="width:100%">
    			<tr>
    			<td>URL:</td><td><input type="text" name="url" value="" size="60"></td>
    			</tr>
    			<tr>
    
    			<td>Tags:</td><td><input type="text" id="tags" name="tags" size="60"><br>
    			Common Tags: <a href="javascript:addtag('Free')">Free</a>, <a href="javascript:addtag('Paid')">Paid</a>, <a href="javascript:addtag('Recip')">Recip</a>
    			</td>
    			</tr>
    
    HTML:
    any ideas....?
     
    falcondriver, Nov 25, 2006 IP
  2. lbalance

    lbalance Peon

    Messages:
    381
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change your line to this:
    document.forms['submitform'].tags.value = document.forms['submitform'].tags.value + tagname;
    Code (markup):
     
    lbalance, Nov 25, 2006 IP