Link to home
Start Free TrialLog in
Avatar of kaciebug
kaciebug

asked on

Embed an actual Href within a textarea within a form

I have a text area on a form where users can enter summaries.  this form is submitted to a database.  I have a web page that pulls the information from the db and displays it on the page.

My problem is if the user wants to make a reference to a link without actually writing the <a href...link...</a> in the text area.

Does anyone have any methods they can share with me as to how to handle this?

Thanks in advance
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

You will need to agree on a way to pass it - for example [>address>text<]
and then do something like

newText = document.myForm.myArea.value

if (newtext.indexOf('[') !=-1) {
   newText = newText.split('[>').join('<a href="');
   newText = newText.split('>').join('">');
   newText = newText.split('<]').join('</a>');
}
Avatar of Red_Baron
Red_Baron

You could just look for the general things that make up a url/hyperlink. The "www." or ".com,org,net" start/endings. Using mplungian's code above can also be used for this approach I believe.
--
Red Baron
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kaciebug

ASKER

this works however, I need to post this to the database in the html format so what actually appears on teh page after submission is an actual hyper link they can click on.  Any thoughts will will be appreciated...
this works however, I need to post this to the database in the html format so what actually appears on teh page after submission is an actual hyper link they can click on.  Any thoughts will will be appreciated...
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

Cd&
points, please
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to mplungjan

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
Thanks, Cd&.  Finalized today.
Moondancer - EE Moderator