Create ASP variable from text on page?


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></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"></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.
LVL 16
Who is Participating?
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"></a></p>
something like that:

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

Open in new window

JF0Author Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.