Jump to content


Using Text Area

  • Please log in to reply
1 reply to this topic

#1 paul.mearing

  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 March 2006 - 11:45 AM


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,


#2 Gast

  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 23 March 2006 - 11:21 AM

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:

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

Or something similar.
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users