ASP Form error

Reply

Join Date: Aug 2004
Posts: 3
Reputation: Nyall is an unknown quantity at this point 
Solved Threads: 0
Nyall Nyall is offline Offline
Newbie Poster

ASP Form error

 
0
  #1
Feb 7th, 2008
hi guys,.. am trying to get this asp form to send the information it has to me, however.. i keep running in to brick walls, as it returns fine, just with no information. so you can imagine its not ideal.

anyway, ill supply the code here, i know its to do with the av_sent.asp file, i just cant figure out where as the cdoMessage.Textbody line confuses me. i have all these feilds that need information to be attached to them and im coming up short.

cheers in advance.

nyall



this is the av_sent.asp

  1. <%
  2. theSchema="http://schemas.microsoft.com/cdo/configuration/"
  3. Set cdoConfig=server.CreateObject("CDO.Configuration")
  4. cdoConfig.Fields.Item(theSchema & "sendusing")=2
  5. cdoConfig.Fields.Item(theSchema & "smtpserver")="pegasus"
  6. cdoConfig.Fields.Update
  7.  
  8. set CdoMessage=Server.CreateObject("CDO.Message")
  9. cdoMessage.Configuration=cdoConfig
  10.  
  11. cdoMessage.From=request.form("emailAddress")
  12. cdoMessage.To="itservices@someplace.org.uk"
  13. cdoMessage.Subject=request.form("name")
  14. cdoMessage.TextBody=request.form("body")
  15.  
  16. cdoMessage.Send
  17.  
  18. Set cdoMessage=Nothing
  19. Set cdoConfig=Nothing
  20.  
  21. %>
  22.  
  23. <html><!-- #BeginTemplate "/Templates/rightframe.dwt" --><!-- DW6 -->
  24. <head>
  25. <!-- #BeginEditable "doctitle" -->
  26. <title>IT</title>
  27. <!-- #EndEditable -->
  28. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  29. <link rel="stylesheet" href="../../../IntranetStyle.css" type="text/css">
  30. </head>
  31.  
  32. <body bgcolor="#FFFFFF" text="#000000">
  33. <!-- #BeginEditable "body" -->
  34. <table width="80%" border="0" cellspacing="0" cellpadding="0" class="regulartext">
  35. <tr>
  36. <td><img src="images/it.gif" width="43" height="29"><a name="Top"></a></td>
  37. </tr>
  38. <tr>
  39. <td width="97%" class="RegularText" height="12" valign="top"><p>&nbsp;</p>
  40. <p>Thank<span lang="en-gb"> </span>you<span lang="en-gb">,</span> your message has now been sent to the
  41. <span lang="en-gb">IT</span> helpdesk, w<span lang="en-gb">ho</span> will be in touch shortly.</p>
  42. <p>IT Department </p>
  43. <p>&nbsp;</p></td>
  44. </tr>
  45. </table>
  46. <!-- #EndEditable -->
  47. </body>
  48. <!-- #EndTemplate --></html>


This is the main form asp file:


  1. <html><!-- #BeginTemplate "/Templates/rightframe.dwt" --><!-- DW6 -->
  2. <head>
  3. <!-- #BeginEditable "doctitle" -->
  4. <title>AV Support</title>
  5. <style type="text/css">
  6. <!--
  7. .style3 {font-size: 9pt}
  8. .style4 {
  9. white-space: normal;
  10. }
  11. .style5 {
  12. margin-bottom: 0px;
  13. }
  14. -->
  15. </style>
  16. <script type="text/JavaScript">
  17. <!--
  18. function MM_findObj(n, d) { //v4.01
  19.   var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>
  20. 0&&parent.frames.length) {
  21. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  22. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  23. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  24. if(!x && d.getElementById) x=d.getElementById(n); return x;
  25. }
  26.  
  27. function MM_validateForm() { //v4.0
  28. var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  29. for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
  30. if (val) { nm=val.name; if ((val=val.value)!="") {
  31. if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
  32. if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
  33. } else if (test!='R') { num = parseFloat(val);
  34. if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
  35. if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
  36. min=test.substring(8,p); max=test.substring(p+1);
  37. if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
  38. } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  39. } if (errors) alert('The following error(s) occurred:\n'+errors);
  40. document.MM_returnValue = (errors == '');
  41. }
  42. //-->
  43. </script>
  44. <!-- #EndEditable -->
  45. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  46. <link rel="stylesheet" href="../IntranetStyle.css" type="text/css">
  47. </head>
  48.  
  49. <body bgcolor="#FFFFFF" text="#000000">
  50. <!-- #BeginEditable "body" -->
  51. <table width="60%" border="0" cellspacing="0" cellpadding="0" class="regulartext">
  52. <tr>
  53. <td><img src="images/it.gif" width="43" height="29"><a name="Top"></a></td>
  54. </tr>
  55. <tr>
  56. <td width="97%" class="RegularText" height="12" valign="top">&nbsp;</td>
  57. </tr>
  58. <tr>
  59. <td class="heading" height="12" valign="top">IT Service Desk </td>
  60. </tr>
  61. <tr>
  62. <td class="RegularText" height="12" valign="top">&nbsp;</td>
  63. </tr>
  64. <tr>
  65. <td class="RegularText"><p style="width: 580px">Please use the form below to request AV support for a presentation. This form must be submitted <strong>at least three working days</strong>
  66. before the presentation dat<span lang="en-gb">e.</span></p>
  67. <p>&nbsp;<span lang="en-gb">IT</span> Department </p>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="regulartext">&nbsp;</td>
  72. </tr>
  73. <tr>
  74. <td class="regulartext">&nbsp;</td>
  75. </tr>
  76. <tr>
  77. <td class="regulartext"><form action="av_sent.asp" method="POST" name="frm_message" id="frm_message">
  78. <table width="583" border="0" cellpadding="3" bgcolor="#CCCCFF" class="style5">
  79. <tr valign="middle">
  80. <td class="SubHeading" style="width: 38%">
  81. <span lang="en-gb" class="heading">Email</span></td>
  82. <td width="66%"><label>
  83. <input name="emailAddress" type="text" class="RegularText" id="emailAddress" size="55">
  84. </label></td>
  85. </tr>
  86. <tr align="left" valign="middle">
  87. <td class="heading" style="width: 38%; height: 34px;">
  88. <span lang="en-gb" class="heading">Name</span></td>
  89. <td style="height: 34px"><label>
  90. <input name="name" type="text" class="RegularText" id="name" size="55">
  91. </label></td>
  92. </tr>
  93. <tr valign="middle">
  94. <td class="SubHeading" style="width: 38%"><span lang="en-gb">Type/
  95. Title of Presentation<br>
  96. <span class="heading">(eg. General
  97. Studies, Tutorial)</span></span><span class="style3"> </span></td>
  98. <td><label>
  99. <input name="subject" type="text" class="RegularText" id="subject" size="55">
  100. </label></td>
  101. </tr>
  102. <tr>
  103. <td style="width: 38%"><span lang="en-gb">Date of Presentation</span></td>
  104. <td><a href="javascript:;" onClick="window.open('popup.aspx?textbox=date','cal','width=250,height=225')">
  105. Please click here to select a date</a>
  106. <input name="date" type="text" id="date" size="15" runat="server" style="width: 137px"> </td>
  107. </tr>
  108. <tr>
  109. <td style="width: 38%"><span lang="en-gb">Time of Presentation<br>
  110. <span class="heading">(eg. Period 4,
  111. Assembly)</span></span></td>
  112. <td><label>
  113. <input name="Time" type="text" class="RegularText" id="Time" size="55"></label></td>
  114. </tr>
  115. <tr>
  116. <td style="width: 38%"><span lang="en-gb">Location of presentation <br>
  117. <span class="heading">(eg. Big
  118. School, DHA)</span></span></td>
  119. <td class="style4"><label>
  120. <input name="Location" type="text" class="RegularText" id="Location" size="55"></label></td>
  121. </tr>
  122. <tr>
  123. <td style="width: 38%; height: 62px">Please provide an overview of<span lang="en-gb" class="heading">
  124. your presentation<br>
  125. <span class="heading">(eg. 'Run a
  126. PowerPoint presentation')</span></span></td>
  127. <td style="height: 62px"><label>
  128. <textarea name="overveiw" class="RegularText" id="overveiw" style="width: 337px; height: 33px" rows="1" cols="20"></textarea></label>&nbsp;</td>
  129. </tr>
  130. <tr>
  131. <td style="width: 38%" class="heading">Will you be providing any equipment and/or
  132. media?<br>
  133. (eg. laptop, slide projector, OHP)<br></td>
  134. <td><label>
  135. <textarea name="equipment" class="RegularText" id="equipment" style="width: 337px; height: 33px" rows="1" cols="20"></textarea></label></td>
  136. </tr>
  137. <tr>
  138. <td style="width: 38%">Will you require any equipment? Please specify
  139. <span lang="en-gb" class="heading">here.<br>
  140. (eg. laptop, projector &amp; screen, speakers, microphone, slide projector,
  141. OHP)</span><br></td>
  142. <td><label>
  143. <textarea name="requirement" class="RegularText" id="requirement" style="width: 337px; height: 33px" rows="1" cols="20"></textarea></label></td>
  144. </tr>
  145. <tr>
  146. <td style="width: 38%" class="heading">Please leave any additional information
  147. <span lang="en-gb">here.</span></td>
  148. <td><label>
  149. <textarea name="moreinfo" class="RegularText" id="moreinfo" style="width: 337px; height: 33px" rows="1" cols="20"></textarea></label></td>
  150. </tr>
  151. <tr>
  152. <td style="width: 38%">&nbsp;</td>
  153. <td><label>
  154. <input name="Submit" type="submit" onClick="MM_validateForm('emailAddress','','RisEmail','name','','R','Title','','R','date','','R','Time','','R','Location','','R','overveiw','','R');return document.MM_returnValue" value="Submit">
  155. <span lang="en-gb">&nbsp; </span>
  156. <input name="Reset1" type="reset" value="reset" style="width: 59px"></label></td>
  157. </tr>
  158. </table>
  159. <p style="width: 579px">If you are supplying media to run on our equipment<span lang="en-gb">,
  160. Please give your media to joe blogs, Resources Technician, <strong>at
  161. least three working days</strong> prior to the presentation.</span></p>
  162. </form>
  163. <p style="width: 577px"><span lang="en-gb">If you are supplying equipment to run your media
  164. Please supply your equipment and media to Joe Blogs, Resources
  165. Technician, as early as possible on the day of the event and ensure that you
  166. have tested the media on your equipment in advance of the presentation. If
  167. supplying a laptop, please ensure that it is Windows-compatible.</span></p>
  168. </td>
  169. </tr>
  170. <tr>
  171. <td>&nbsp;</td>
  172. </tr>
  173. </table>
  174. <!-- #EndEditable -->
  175. </body>
  176. <!-- #EndTemplate --></html>
Last edited by peter_budo; Feb 10th, 2008 at 6:34 am. Reason: Please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 62
Reputation: a496761 is an unknown quantity at this point 
Solved Threads: 4
a496761 a496761 is offline Offline
Junior Poster in Training

Re: ASP Form error

 
0
  #2
Feb 7th, 2008
It looks like you're assigning the TextBody property of your CDO message to Request.Form("body") and you don't have an input element on your form named body. You'll want to do something like this...

  1. Dim strBody
  2. strBody = "Required Equipment: " & Request.Form("requirement")
  3. cdoMessage.TextBody = strBody

Make sense? If not just let us know.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 3
Reputation: Nyall is an unknown quantity at this point 
Solved Threads: 0
Nyall Nyall is offline Offline
Newbie Poster

Re: ASP Form error

 
0
  #3
Feb 8th, 2008
thanks for the reply,

i kinda understand, i realised it had to do with that section of the html, i just lack the understanding of how to include all of the text fields, rather 'glue' them together so it sends all the info. ill give it a bash with what you suggested, although i have to admit i get easily confused, especially about the textbody line

cheers

nyall

p.s

this may sound stupid.. but ill never know otherwise. can i not just add the names of the txt fields to the code.. like..

cdoMessage.From=request.form("emailAddress")
cdoMessage.To="itservices@someplace.org.uk"
cdoMessage.Subject=request.form("name")
cdoMessage.Required equipment =request.form("required")
cdoMessage.TextBody=request.form("body")

eg^

cheers
Last edited by Nyall; Feb 8th, 2008 at 5:03 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 62
Reputation: a496761 is an unknown quantity at this point 
Solved Threads: 4
a496761 a496761 is offline Offline
Junior Poster in Training

Re: ASP Form error

 
0
  #4
Feb 8th, 2008
It doesn't really work like that. The TextBody (or HTMLBody) is the only property that will be included as the body of the email. So you will want to assign everything that you want in the email body to one of those properties. You can use the format below to do this:

  1. cdoMessage.TextBody = "Required Equipment: " & Request.Form("required") & vbNewLine
  2.  
  3. 'use the following line as a guide when adding more fields to the email, not the previous line
  4.  
  5. cdoMessage.TextBody = cdoMessage.TextBody & "Additional Information: " & Request.Form("moreinfo") & vbNewLine

Hope this cleared it up for you.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 3
Reputation: Nyall is an unknown quantity at this point 
Solved Threads: 0
Nyall Nyall is offline Offline
Newbie Poster

Re: ASP Form error

 
0
  #5
Feb 14th, 2008
many thanks mate, i will endevour to use what you hve written to try and get this form off the ground, tho im sure ill end up confused again heh

cheers

nyall
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC