Create ASP variable from text on page?

Posted on 2011-10-14
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></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.
Question by:JF0
    LVL 15

    Expert Comment

    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

    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>
    LVL 16

    Author Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    json example 39 80
    Spacing between <li> 3 13
    SharePoint CAML Query - retrieving field names 3 15
    javascript to html map 8 15
    Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now