Jump to content

Archived

This topic is now archived and is closed to further replies.

paul.mearing

Using Text Area

Recommended Posts

Hi,

I've seen on sites how you can have a normal input button which allows you to insert text into the box. I want to have a button that will insert a html tag where ever the cursor is in the text area. I.e. if i have just typed a URL, I would like to be able to highlight this and then click on the hyperlink button. this would insert the h ref tag and closed tag and the start and finsish so this becomes a link.

Is this possible just using javascript / html, or would i need to find a rich text editor like what is used when you add a new topic / post??

Would appreciate your input,

Cheers
Paul.

Share this post


Link to post
Share on other sites
Not sure exactly how to have it so that when you select the text and then click the button it adds tags around it, but you can do this:

[code]<input type="button" value="HREF Tag" onclick="document.getElementById('textareaid').value = document.getElementById('textareaid').value + '<a href=\"\"></a>'" />[/code]

Or something similar.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.