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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.