quick javascript writer thing
August 18, 2006 12:14 PM   RSS feed for this thread 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 comments 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 Any worthwhile online photogra...   |   Cheap wide shoes online in Can... Newer »

You are not logged in, either login or create an account to post comments



Related Questions
Does anyone know of a way to create a line graph... July 30, 2007
java(script) filter help me please! July 5, 2007
stop scrolling, damn ye! May 2, 2007
My Multi Select UI Sucks. Help me make it better January 7, 2007
Help Me Teach Programming July 18, 2005