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 ?
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.
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.