Link to home
Start Free TrialLog in
Avatar of JF0
JF0Flag for United States of America

asked on

Create ASP variable from text on page?

Hello,

I am not very good at scripting. Searched but could not find exactly what I needed. Hopefully one of you experts will be able to assist me.

I have a web page where I have defined editable sections for my customer through a hosted CMS. The CMS allows the user to edit data so long as a specific CSS class is applied to it. An editable section looks something like this:

 
<p class="editable>EmailAddress@123.com</p>

Open in new window


My users will update the Email Address between the paragraph tags. So far so good. But, I also want to make the Email Address a link. So now I have something like this:

 
<p class="editable><a href="mailto:xxxxx">EmailAddress@123.com</a></p>

Open in new window


So my question is, how am I able to grab the email address from between the paragraph tags and place it in the link before it? It shows xxxx in the link where i need the email address to be.

Thank you in advance.
Avatar of Eyal
Eyal
Flag of Israel image

something like that:

var emailAddrP = getElementById('P_ID')
emailAddrP.innerHTML = '<a href="mailto:'+emailAddrP.innerText+'">'+emailAddrP.innerText+'</a>';

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of pateljitu
pateljitu
Flag of Canada 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 JF0

ASKER

Thanks for the answers.

pateljitu, this script does work, however, i was hoping to write the variable to the link instead of having it generated only onclick.