This seems to be pretty basic but I cannot get it exactly the way I want it. Note: I have been looking for 4 days on how to resolve this. Issue: I created a form to be used on my work intranet (ie7 / Outlook) which will email the form textarea answers to the specified email address via Mailto (plain/text) and I want to add a carriage return after each text area on submit. Reason: This is for a staff quiz page (no access to php on this server so using mailto), and the text is too cramped when sent by the email. I want to add spacers between each question response. What I have working: This works but only on the textarea with ID = A1 and I have it as an onchange event. My form does not have a submit button (sent via another script) so I also not sure how to execure onSubmit. <SCRIPT LANGUAGE=JavaScript> function DisplayEvent(eventName){ var myMessage = window.document.frm.a1.value; myMessage = myMessage + eventName; window.document.frm.a1.value = myMessage; } </SCRIPT> Code (markup): Much appreciate any help you can give. Here is a stripped down example of my form (note: i added in the submit button for the example) <FORM NAME="mailer" id="frm" METHOD="post" ACTION="" ENCTYPE="text/plain" onSubmit="(document.mailer.action += mailtoandsubject)" > To Mail:<input type="text" NAME="mailtoperson" onChange="msg(this.form)" /><BR /> <INPUT TYPE="hidden" SIZE=45 NAME="Enter Quiz Title Here" onChange="msg(this.form)" /> <INPUT TYPE="hidden" SIZE=45 NAME="subject" value="Enter Quiz Title Here - hidden" onChange="msg(this.form)" /> Q1: <textarea name="1" id="styled" cols="22" rows="5" onChange="msg(this.form)"></textarea><br/> Q2: <textarea name="2" id="styled" cols="22" rows="5" onChange="msg(this.form)"></textarea><br/> Q3: <textarea name="3" id="styled" cols="22" rows="5" onChange="msg(this.form)"></textarea><br/> <input type="submit"> </form> <script type="text/javascript"> function msg() { document.mailer.action = "mailto:" mailtoandsubject = ( ( document.mailer.mailtoperson.value) + '?subject=' + document.mailer.subject.value ); } </script> Code (markup):
Looks to me like you've got a bunch of javascript for nothing to do something better handled using a host-side script instead of client-side scripting... to go with the invalid use of ID, obvious HTML 3.2 style code, outdated methodology of using the various onevent attributes, complete lack of graceful degradation, and on the whole a laundry list of how not to write HTML any time after 1997. Make it work without scripting before you dive for the client side stuff.
Tell me how you really feel. Since nobody actually uses mailto for this purpose anymore you are right the answers did come from sites circa 1998, but without a serverside option I had to find answers somewhere. And in case anybody wants to know I resolved this with some jquery: $('#frm').submit(function() { $(this).find("textarea").each(function(){ $(this).val( $(this).val() + '\n\n' ); }); }) Code (markup):