quick javascript writer thing
August 18, 2006 12:14 PM   Subscribe

I'd like some premade javascript that adds text into a text input when clicked, sounds simple but I cant find anything on the web. anyone know of a script that can help me out?
posted by yeahyeahyeahwhoo to Computers & Internet (3 answers total)
 
Sure: right here on Metafilter. Look at how the "bold", "italic", and "link" buttons work in the comment entry form for this site.
posted by Steven C. Den Beste at 12:16 PM on August 18, 2006


function addToInputtBox( c, text ) {
c.value += text ;
}

Call the function witthe the input and the text you want to add.
posted by orthogonality at 2:42 PM on August 18, 2006


Either (using a separate link to add the text):

<input id="whatever">

<a href="javascript:document.getElementById('whatever').value+='text to add'">Add text</a>

or (adding the text whenever you click the field):

<input onclick="this.value+='text to add'">

(I'm not sure which you're asking for)
posted by cillit bang at 4:26 PM on August 18, 2006


« Older Online photography course recommendations?   |   Online canadian shoe source Newer »
This thread is closed to new comments.