getting a perticular div content and send it through php email

Discussion in 'PHP' started by hansab, Apr 3, 2010.

  1. #1
    Ok i really need this done today and if you can help me i will be grateful to you.

    Let's say i have a

    <div id="contents">
    contents contentscontents
    contentscontentscontents
    </div>

    What i want is, when i click on a email to friend link, the whole data in this div should be emailed to the email address.

    What i want is to add this div content in a variable(text area) and then send it through email. But with a click.

    Any ideas ?
     
    hansab, Apr 3, 2010 IP
  2. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #2
    Using a form, something like this...

    <script>
    function emailToFriend()
    {
    document.getElementById("htmlContents").value = document.getElementById("contents").innerHTML;
    document.getElementById("friendForm").submit();
    }
    </script>
    HTML:
    <form id="friendForm" onSubmit="return emailToFriend();">
    <input name="htmlContents" value="" type="hidden"/>
    <input name="submitButton" type="submit" value="send to friend"/>
    </form>
    HTML:
    Completely untested, but that's the principle. You'll obviously need to add the method/action to the form and you may need to escape the html when setting it on the hidden element.
     
    mfscripts, Apr 3, 2010 IP
  3. Brandon.Add.On

    Brandon.Add.On Peon

    Messages:
    178
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think the person above me got it with the exception that you wanted a textarea but he put it in a hidden text field. You can easily fix that by making a textarea with the name and id of htmlContents.
     
    Brandon.Add.On, Apr 3, 2010 IP
  4. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #4
    Yeap text area will do it too, just set a style with a display:none on it to hide it.
     
    mfscripts, Apr 3, 2010 IP