Jump to content

animockery
 Share

Recommended Posts

I am creating a form that is captured and placed in an email. I have managed to do this fine with the exception of one item. when getting the value of a text area it will not maintain the user entered format. Thsi will be important when recieving the information in the email. what I need is this, when a user enters the below info in a textarea;---example---Reference line 1Reference line 2Reference line 3Reference line 4----------------- I need it to popluate in the email the same way. When I pull this infor like a normal input it comes out like this; Reference line 1Reference line 2Reference line 3Reference line 4 can anyone help? I am not able to use PHP in my environment I am working with, as I understand it now. I also do not know much about asp.net

Link to comment
Share on other sites

There a great deal of conditions added in to some parts but the basics of the script are below; -JavaScript- To= document.myform.Approvermail.value ;Subject="SQL Access Request";BHeader= "**"+document.myform.Approvername.value+", Please approve this request and reply to all.**"Body= "Server Name - "+document.myform.Servername.value+ "";Body2= "Database Name - "+document.myform.Databasename.value+ "";Body3= "Access Groups:";Body3a= document.myform.Accessgroups1.value ;Body3b= document.myform.Accessgroups2.value ;Body3c= document.myform.Accessgroups3.value ;Body3d= document.myform.Accessgroups4.value ;Body3e= document.myform.Accessgroups5.value ;Body3a1= ""+al1Aval+""+al1Bval+""+al1Dval+""+al1Eval+""+al1Gval+""+al1GRval+""+al1Ival+""+al1Lval+""+al1Sval+""+al1Tval+""+al1Uval+" ";Body3b2= ""+al2Aval+""+al2Bval+""+al2Dval+""+al2Eval+""+al2Gval+""+al2GRval+""+al2Ival+""+al2Lval+""+al2Sval+""+al2Tval+""+al2Uval+" ";Body3c3= ""+al3Aval+""+al3Bval+""+al3Dval+""+al3Eval+""+al3Gval+""+al3GRval+""+al3Ival+""+al3Lval+""+al3Sval+""+al3Tval+""+al3Uval+" ";Body3d4= ""+al4Aval+""+al4Bval+""+al4Dval+""+al4Eval+""+al4Gval+""+al4GRval+""+al4Ival+""+al4Lval+""+al4Sval+""+al4Tval+""+al4Uval+" ";Body3e5= ""+al5Aval+""+al5Bval+""+al5Dval+""+al5Eval+""+al5Gval+""+al5GRval+""+al5Ival+""+al5Lval+""+al5Sval+""+al5Tval+""+al5Uval+" ";Body3a1x= ng1val ;Body3b2x= ng2val ;Body3c3x= ng3val ;Body3d4x= ng4val ;Body3e5x= ng5val ;Body4= document.myform.tables.value ; location = "mailto:"+To+"?CC=email@example.com?subject="+Subject+"&Body="+BHeader+"%0d%0A%0d%0A"+Body+"%0d%0A%0d%0A"+Body2+"%0d%0A%0d%0A"+Body3+"%0d%0A Group= "+Body3a+" Access= "+Body3a1+" "+Body3a1x+"%0d%0A Group= "+Body3b+" Access= "+Body3b2+" "+Body3b2x+"%0d%0A Group= "+Body3c+" Access= "+Body3c3+" "+Body3c3x+"%0d%0A Group= "+Body3d+" Access= "+Body3d4+" "+Body3d4x+"%0d%0A Group= "+Body3e+" Access= "+Body3e5+" "+Body3e5x+"%0d%0A%0d%0A Owner/Tables= "+Body4+" ";} -Form- <FORM onclick="" name=myform NewEmail(myForm) return> <P align=left><B>Approving Manager/Supervisor Name:*</B> <BR><INPUT style="WIDTH: 280px" type=email name=Approvername> </P><P align=left><B>Approving Manager/Supervisor Email:*</B> <BR><INPUT style="WIDTH: 280px" name=Approvermail> </P><P align=left><B>Server name:*</B> <BR><INPUT style="WIDTH: 280px" name=Servername> </P><P align=left><B>Database name:</B>* <BR><INPUT style="WIDTH: 280px" name=Databasename> </P> <P><br /><b>Access Permission(s):</b><br /> <fieldset Style="width: 15%"><b>Netezza Group:</b><INPUT style="WIDTH: 110px" name=Accessgroups1><u>New Group?</u><input type="checkbox" title="New Group" name="ng1"><p> <input type="checkbox" name="al1A" value="Abort, ">Abort<br /> <input type="checkbox" name="al1B" value="Alter, ">Alter<br /> <input type="checkbox" name="al1D" value="Delete, ">Delete<br /> <input type="checkbox" name="al1E" value="Execute, ">Execute<br /> <input type="checkbox" name="al1G" value="Gen Stats, ">Gen Stats<br /> <input type="checkbox" name="al1GR" value="Groom, ">Groom<br /> <input type="checkbox" name="al1I" value="Insert, ">Insert<br /> <input type="checkbox" name="al1L" value="List, ">List<br /> <input type="checkbox" name="al1S" value="Select, ">Select<br /> <input type="checkbox" name="al1T" value="Truncate, ">Truncate<br /> <input type="checkbox" name="al1U" value="Update, ">Update<br /> </p> </fieldset> <fieldset Style="width: 15%"><b>Netezza Group:</b><INPUT style="WIDTH: 110px" name=Accessgroups2><u>New Group?</u><input type="checkbox" title="New Group" name="ng2"><p> <input type="checkbox" name="al2A" value="Abort, ">Abort<br /> <input type="checkbox" name="al2B" value="Alter, ">Alter<br /> <input type="checkbox" name="al2D" value="Delete, ">Delete<br /> <input type="checkbox" name="al2E" value="Execute, ">Execute<br /> <input type="checkbox" name="al2G" value="Gen Stats, ">Gen Stats<br /> <input type="checkbox" name="al2GR" value="Groom, ">Groom<br /> <input type="checkbox" name="al2I" value="Insert, ">Insert<br /> <input type="checkbox" name="al2L" value="List, ">List<br /> <input type="checkbox" name="al2S" value="Select, ">Select<br /> <input type="checkbox" name="al2T" value="Truncate, ">Truncate<br /> <input type="checkbox" name="al2U" value="Update, ">Update<br /> </p> </fieldset> <fieldset Style="width: 15%"><b>Netezza Group:</b><INPUT style="WIDTH: 115px" name=Accessgroups3><u>New Group?</u><input type="checkbox" title="New Group" name="ng3"><p> <input type="checkbox" name="al3A" value="Abort, ">Abort<br /> <input type="checkbox" name="al3B" value="Alter, ">Alter<br /> <input type="checkbox" name="al3D" value="Delete, ">Delete<br /> <input type="checkbox" name="al3E" value="Execute, ">Execute<br /> <input type="checkbox" name="al3G" value="Gen Stats, ">Gen Stats<br /> <input type="checkbox" name="al3GR" value="Groom, ">Groom<br /> <input type="checkbox" name="al3I" value="Insert, ">Insert<br /> <input type="checkbox" name="al3L" value="List, ">List<br /> <input type="checkbox" name="al3S" value="Select, ">Select<br /> <input type="checkbox" name="al3T" value="Truncate, ">Truncate<br /> <input type="checkbox" name="al3U" value="Update, ">Update<br /> </p></fieldset> <fieldset Style="width: 15%"><b>Netezza Group:</b><INPUT style="WIDTH: 115px" name=Accessgroups4><u>New Group?</u><input type="checkbox" title="New Group" name="ng4"><p> <input type="checkbox" name="al4A" value="Abort, ">Abort<br /> <input type="checkbox" name="al4B" value="Alter, ">Alter<br /> <input type="checkbox" name="al4D" value="Delete, ">Delete<br /> <input type="checkbox" name="al4E" value="Execute, ">Execute<br /> <input type="checkbox" name="al4G" value="Gen Stats, ">Gen Stats<br /> <input type="checkbox" name="al4GR" value="Groom, ">Groom<br /> <input type="checkbox" name="al4I" value="Insert, ">Insert<br /> <input type="checkbox" name="al4L" value="List, ">List<br /> <input type="checkbox" name="al4S" value="Select, ">Select<br /> <input type="checkbox" name="al4T" value="Truncate, ">Truncate<br /> <input type="checkbox" name="al4U" value="Update, ">Update<br /> </p></fieldset> <fieldset Style="width: 15%"><b>Netezza Group:</b><INPUT style="WIDTH: 115px" name=Accessgroups5><u>New Group?</u><input type="checkbox" title="New Group" name="ng5"><p> <input type="checkbox" name="al5A" value="Abort, ">Abort<br /> <input type="checkbox" name="al5B" value="Alter, ">Alter<br /> <input type="checkbox" name="al5D" value="Delete, ">Delete<br /> <input type="checkbox" name="al5E" value="Execute, ">Execute<br /> <input type="checkbox" name="al5G" value="Gen Stats, ">Gen Stats<br /> <input type="checkbox" name="al5GR" value="Groom, ">Groom<br /> <input type="checkbox" name="al5I" value="Insert, ">Insert<br /> <input type="checkbox" name="al5L" value="List, ">List<br /> <input type="checkbox" name="al5S" value="Select, ">Select<br /> <input type="checkbox" name="al5T" value="Truncate, ">Truncate<br /> <input type="checkbox" name="al5U" value="Update, ">Update<br /> </p></fieldset></p><br /><p><b>Owner/Table(s):*</><br /><textarea id="tables" name="tables" rows="10" style="width: 600px" ></textarea><br /> </p><br /><br /> <INPUT id=sub onclick="location.href='javascript:SQLEmail()'" value=Submit type=button> <span> <input type="reset"> </FORM> The only thing I cannot get is the text area to stay in the format entered by the user.

Edited by animockery
Link to comment
Share on other sites

It's staying in the same format, but it sounds like the email client is not displaying it that way because it's an HTML email. In HTML instead of a normal line break you need to use a <br> tag, so you should replace line breaks in the text field with <br> tags before redirecting the user. The other possibility is that you need to replace line breaks with their corresponding ASCII URL codes. You can use the encodeURIComponent function to do that automatically.

Link to comment
Share on other sites

So to get the return, or the output that will be referenced into the email body I need to do a replace? I do not think I am familiar with how to do this but I would like to learn how. Can I get an example of how this would look if I want the line breaks inserted by the user to hold true in an email?

Link to comment
Share on other sites

It's the same format you have here: Body="+BHeader+"%0d%0A%0d%0A"+Body+"%0d%0A%0d%0A" The %0D%0A is a line break. The body text doesn't contain those character codes, which I assume is the problem. You can verify that for yourself though, instead of setting the location to that string use alert so that you can see what it looks like. If you see actual line separation instead of the character codes to indicate a line break then that's the issue. The encodeURIComponent function will convert any characters that need to be converted to their respective character codes. http://www.w3schools.com/jsref/jsref_encodeuricomponent.asphttps://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent Use that function to convert the body text when you add it to the location string.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...