Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hyperlink into textarea 1

Status
Not open for further replies.

codecomm

Programmer
Feb 14, 2007
121
US
I have a textarea that gets populates when users click on hyperlinks.

What I'm trying to do via one of the links is insert a mailto: hyperlink, but I can't get it to work:

here's my .js code:

document.getElementById('servicestext').value = "Click the sales link here
'<a href="' + mailto:sales@sales.com + '">' + sales@sales.com + '</a>' to help us help you!";

The error I get back is object expected which points to the html page containing the hyperlink, not to the .js file.
 
textarea is a form input element. Its basic purpose is to provide user to send "long" character text to server editable before submitting it. It is not the place where server (or page designer) to enhance use's surfing experience dynamically or statically - not at all.

To dynamically enhancing user's pleasure with hyperlink or other html control elements provision by the page design, you use other means. Generating hyperlink as a finality, you can use div; generating hyperlink and more complicated design, you can even iframe to compose and render the whole html page.

On a more theoretical basis why you shouldn't do so with textarea, you can check out my response to a recent thread.
 
Not sure about your apostrophes.
This should do it:

document.getElementById('servicestext').value = "Click the sales link here <a href='mailto:sales@sales.com'> sales@sales.com</a> to help us help you!";
 
Hi all!

I did try dexeloper's suggestion, and the textarea still shows the anchor tags, and it's not in a format for the user to click....thanks for the suggestion though.

So, I would need to simply change the textarea to a DIV...right?

Thanks!
 
The <div> wouldn't be edittable like the textarea, which is basically what tsuji said. Is that what you're looking for?

Lee
 
Apologies. I, sort of, wasted your time.
Assuming you are trying to create text that will be displayed you can invent your own tags (say <w><w>) and when displaying render them as anchors.
Thus <w>bbc.co.uk<w> becomes:
<a href='bbc.co.uk'>bbc.co.uk</a>
Just a thought.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top