Jump to content

Using Text Area


paul.mearing

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.
Link to comment
https://forums.phpfreaks.com/topic/5337-using-text-area/
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.
Link to comment
https://forums.phpfreaks.com/topic/5337-using-text-area/#findComment-19901
Share on other sites

Archived

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

×
×
  • Create New...

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.