[SOLVED] Add text to existing text in textarea

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

[SOLVED] Add text to existing text in textarea

Post 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
Last edited by benyboi on Sun Feb 25, 2007 7:06 pm, edited 1 time in total.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

Could you possibly point me in the right direction?

Thank you very much.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

use jQuery!

Code: Select all

$('#textAreaId').append("\n this is some footer text");
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

Thanks for that.
Does it need any <script> type brackets?
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

how would i make a hyperlink do it?
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

Actually, don't think i can use it. I have windows server.
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

Solved
Post Reply