Create ASP variable from text on page?

Posted on 2011-10-14
Medium Priority
Last Modified: 2012-06-27

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.
Question by:JF0
LVL 15

Expert Comment

ID: 36970165
something like that:

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

Open in new window

LVL 15

Accepted Solution

pateljitu earned 1600 total points
ID: 36970213
Please try this script:

<script type="text/javascript" language="javascript">
function callMailto(){
    window.location.href = "mailto:"+ document.getElementById("someId").innerHTML;


<p class="editable"><a href="javascript:onclick=callMailto();" id="someId">EmailAddress@123.com</a></p>
LVL 16

Author Comment

ID: 36971159
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.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question