Jump to content

A strange function


adrianle

Recommended Posts

So I have a client that wants me to add a function to her site that when she clicks a mailto href on a page to spawn an email child, some canned data chunk gets inserted into a form's textarea field.. something like:  "Email sent to blah@blah.com on 8/14/14".   

 

I'm drawing a blank on how this might be handled.. any ideas out there??

Link to comment
Share on other sites

You're going to have to give a bit more to go on than that, it doesn't make much sense what you/her are asking.  But I'm pretty sure you'll need a little javascript at minimum to block the default behavior action of the mailto href and possibly to place the text in the text field depending on how you want to achieve this.

Link to comment
Share on other sites

Or maybe something like this?

<!DOCTYPE html>
<html>
<head>
<title>Sample</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type='text/javascript'>
    function logEmail(name)
    {
        var dt = new Date();
        var date = dt.toLocaleDateString();
        var time = dt.toLocaleTimeString();
        $("#ta").append("Email sent at "+date+" "+time+" to "+name+"\n" );
    }

    $().ready(function(){
        $(".mail").click(function(){
            logEmail($(this).html());
        })
    })
</script>
</head>
<body>
Mail: <a id='mail1' class='mail' href="mailto:john.doe@gmail.com">John Doe</a><br>
Mail: <a id='mail2' class='mail' href="mailto:jane.doe@gmail.com">Jane Doe</a><br>
<textarea id='ta' cols='60' rows='5'></textarea>
</body>
</html>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.