Page 1 of 1
[SOLVED] Add text to existing text in textarea
Posted: Sun Feb 25, 2007 3:14 pm
by benyboi
Hello,
I am creating a blog and below the textarea there will be an options are, and if the user clicks on an image the relevant code will be added at the end of all the text in the textarea. How do i do this? Without a page refresh type thing?
Thanks
Posted: Sun Feb 25, 2007 3:37 pm
by Ambush Commander
JavaScript.
To elaborate, you'll want to retrieve the textarea node, and then append text into the object's value property. If you want to be really cool, you'd also take the position of the cursor into effect and add the text there.
Posted: Sun Feb 25, 2007 3:39 pm
by benyboi
Could you possibly point me in the right direction?
Thank you very much.
Posted: Sun Feb 25, 2007 6:25 pm
by Kieran Huggins
use
jQuery!
Code: Select all
$('#textAreaId').append("\n this is some footer text");
Posted: Sun Feb 25, 2007 6:54 pm
by benyboi
Thanks for that.
Does it need any <script> type brackets?
Posted: Sun Feb 25, 2007 6:58 pm
by benyboi
how would i make a hyperlink do it?
Posted: Sun Feb 25, 2007 7:04 pm
by benyboi
Actually, don't think i can use it. I have windows server.
Posted: Sun Feb 25, 2007 7:05 pm
by benyboi
Solved