Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0

    Exclamation VBscript Form HELP!


    Hello everyone :D

    I need to design a form where the user enters their name, email address and their managers email address.

    Then, the user proceeds to answer "X" multiple choice questions. I want the form to email the users answers, to both the user and the manager.

    Below are some screen shot to better explain:



    As of now the form does absolutely nothing...
    Any insight would be greatly appreciated!

    and the code:
    Code:
    <%@ Language=VBScript %>
          <%
    	Option Explicit
    	Response.Buffer = true
    	Response.Expires = -1000
          %>
    <html>
    <head>
    <title>ESP - Certification - Multiple-Choice Questions</title>
    
    <style type="text/css">
    .button  {border-style: inset;
                border-color: #FAD2A2;
                background-color: #FAD2A2;
                width: 90px;
                text-align: center;
                font-family : Verdana;
                font-weight: bold;
                color : Black;
                font-size: 10pt;
                padding: 1px}		    
    </style>
    
    
    </head>
    
    <body bgcolor="#FFFFFF" text="#000000" vlink="#800080" topmargin="0" leftmargin="0" onload="ChangeOn()" marginheight="0" marginwidth="0" link="#0000FF" alink="#FF0000">
    
    <div id="main">
    <table width="780" border="0" cellspacing="0" cellpadding="5" height="1" align="left">
       <tr bgcolor="#FF909B"> 
        <td width="725" height="6" valign="top" bgcolor="#FF9933">
        <font face="Verdana, Arial, Helvetica, sans-serif" size="4"><b><i>CERTIFICATION</i></b></font>
        </td>
      </tr>
      <tr bgcolor="#FFBFC6" valign="middle"> 
        <td height="13" bgcolor="#FAD2A2">
        <font face="Verdana, Arial, Helvetica, sans-serif" size="4"><b><i>MULTIPLE CHOICE 
        QUESTIONS</i></b></font>
        </td>
      </tr>
      <tr> 
        <td valign="top" height="1">
    
    
    <!-- ------------ INPUT FIELDS START -------------------------------------------------------------------------------------------------- -->
    
    <!-- BELOW ARE THE 3 REQUIRED FIELDS THE USER MUST FILL IN IN ORDER TO SEND THE FORM -->
    
         <%If UCase(Request.Form("Validated") = "VALIDATED") Then%>
    
         <form method="POST" action="<%= Request.ServerVariables("Script_Name")%>" name="frmMain">
         <input type="hidden" name="Validated" id="Validated" value="" />
    
            <input TYPE="hidden" NAME="frmMain" VALUE="0">
            <font face="Verdana, Arial, Helvetica, sans-serif" size="3">Please enter your name and the email address of yourself and your manager.</font>
            <br>
            <br>
    
    <!-- 1ST FIELD IS THE USERS FULL NAME -->  
        <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Name</font>
          <font size="1">
            <br>
            <input type="text" name="name" size="30" style="font-family: Verdana; font-size: 10px">
            <br>
          </font>
        </font><br><br>
    
    <!-- 2ND FIELD IS THE USERS EMAIL ADDRESS -->
        <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Your Email</font>
          <font size="1">
            <br>
            <input type="text" name="email" size="30" style="font-family: Verdana; font-size: 10px">
            <br>
          </font>
        </font><br><br>
    
    <!-- 3RD FIELD IS THE USERS MANAGERS EMAIL ADDRESS -->
        <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Managers Email</font>
          <font size="1">
            <br>
            <input type="text" name="manager" size="30" style="font-family: Verdana; font-size: 10px">
            <br>
          </font>
        </font><br><br>
    
    
    <!-- ONCE THE USER HITS THE SUBMIT BUTTON AT THE BOTTOM OF THE PAGE, THE FORM SHOULD BE SENT
    TO THE EMAIL ADDRESSES THE USER INPUT IN THE ABOVE 2 FIELDS-->
    
    <!-- ------------ INPUT FIELDS END -------------------------------------------------------------------------------------------------- -->
    
    <!-- ------------ BODY OF FORM START -------------------------------------------------------------------------------------------------- -->
    
      </font></span><font size="2"><span style="font-family: Verdana"><b>1. A Sales 
      Competitor Analysis allows you to:</b><br>
      </span></font><span lang="en-us"><font size="2">
      <span style="font-family: Verdana"><input type="radio" value="V1" name="R1">a) 
      Forecast future business<br>
      </span></font><span style="font-size: 12.0pt; font-family: Times New Roman">
      <font size="2"><span style="font-family: Verdana">
      <input type="radio" name="R1" value="V2">b) Talk negatively about your 
      competitors<br>
      <input type="radio" name="R1" value="V3">c) Identify where needs are likely to 
      be found<br>
      <input type="radio" name="R1" value="V4">d) Position your products<br>
       </span></font></span></span></p>
      <p class="MsoBodyText"><font size="2" face="Verdana"><b>2. Which of the 
      following is least important in determining how to position your 
      products/service?</b><br>
      </font><font face="Verdana"><input type="radio" name="R2" value="V1"><span lang="en-us"><font size="2">a)
      </font></span><font size="2">Identify those areas where you are strong and the 
      competitor is weak.<br>
      </font><input type="radio" name="R2" value="V2"><span lang="en-us"><font size="2">b)
      </font></span><font size="2">Identify the customerís needs and how they are 
      currently being met.<br>
      </font><input type="radio" name="R2" value="V3"><span lang="en-us"><font size="2">c)
      </font></span><font size="2">Identify those areas in which you can 
      differentiate yourself from the competition.<br>
      </font></font><span style="font-size: 12.0pt; font-family: Verdana">
      <input type="radio" name="R2" value="V4"></span><span style="font-family: Verdana"><span lang="en-us"><font size="2">d)
      </font></span><font size="2">Identify the decision-makers within the 
      customerís institute.<br>
       </font></span></p>
    
    <!-- ------------ BODY OF FORM END ------------------------------------------------------------------------------------------------------ -->
    
    <!-- ------------ SUBMIT BUTTON START -------------------------------------------------------------------------------------------------- -->
    
    <div align="center">
      <a href="javascript:DoSubmit()" class="button" style="text-decoration: none">
        <font size="1">SUBMIT</font>
      </a>
    </div>
    
    <!-- ------------ SUBMIT BUTTON END ----------------------------------------------------------------------------------------------------- -->
    
    
    <%else SendEmailMessage()%>
        
             </td>
          </table>
        </td>
      </tr>
    </table>
    </div>
    </body>
    </html>
    <%End If%>
    
    <!-- ------------ SEND MAIL CODE START ----------------------------------------------------------------------------------------------------- -->
    
    <% 
    	Sub SendEmailMessage()	
    
    		Dim objMail
    		Dim strBody
    		
    		Set objMail= CreateObject("CDONTS.Newmail")
    		
    		strBody = "<HTML>"
    		strBody = strBody &"<HEAD>"
    		strBody = strBody &"<STYLE>TD{FONT-SIZE:x-small;FONT-FAMILY:Arial}.B {font-weight:700;}.BL {font-weight:700;FONT-SIZE:small;}</STYLE>"
    		strBody = strBody & "</HEAD><BODY>"
    		strBody = strBody & "<TABLE WIDTH='100%' CELLPADDING='0'>"
    		strBody = strBody & "<tr><td> </td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong><h4>ESP Certification Results</h4></strong>" & chr(10)
    		strBody = strBody & "</td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong>Name: </strong>" & Request.Form("name") & chr(10)
    		strBody = strBody & "</td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong>Email: </strong>" & Request.Form("email") & chr(10)
    		strBody = strBody & "</td></tr>"
    		
    		strBody = strBody & " "
    		strBody = strBody & "</TABLE>"
    		strBody = strBody & "</BODY>"
    
    				
    		objMail.BodyFormat = 0'HTML
    		objMail.Body = strBody
    		
    		objMail.MailFormat = 0'Mime format
    		objMail.Importance = 2'High
    
    		objMail.From = "ESP User" 
    		objMail.To = Request.Form("manager") & ", " & Request.Form("name") & "<" & Request.Form("email") & ">"
    		objMail.Subject = "ESP User Certification Results"		
    		
    		objMail.Send
    		
    		Set objMail = Nothing
    	 
    	End Sub 
    %>
    
    <!-- ------------ SEND MAIL CODE END ----------------------------------------------------------------------------------------------------- -->
    
    <!-- ------------ ERROR POP-UP START ----------------------------------------------------------------------------------------------------- -->
    
    <script Language="Javascript">
        
       function DoSubmit()
        {
    		
    		if(frmMain.name.value=="")
    		{
    			window.alert("Your Name is required before submission");
    		}
    
    
    		else
                   {
                      frmMain.Validated.value = 'Validated';
                      frmMain.submit()
                    }
        }
        
    </script>
    
    <!-- ------------ ERROR POP-UP END ------------------------------------------------------------------------------------------------------- -->

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    I think I see what is going on. Your checking to see if the form is validated then displaying it. But if I'm reading it correctly you don't validate the form until it is submitted. So it should not be shown. Is it being shown?

    Again if I'm understanding everything then the send email procedure will never be called unless validated is not true.

    Anyway I could be more help if you explained exactly what is not happing.

    By the way this post really should be in the ASP section .

    Comments on this post

    • JimmyGosling agrees
    Last edited by defjamninja; May 2nd, 2003 at 02:50 PM.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    Basically, when you bring up the page, fill out ALL appropriate
    fields, go through the questions and hit submit, the page reloads
    and thats about it!?!?

    I wish I could post the link to the page but it's part of a corporate intranet.

    my fault for posting here, i'm a newbie to devshed
  6. #4
  7. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    What happens if you change the value of Validated? I think that should cause the page to email the form because
    Code:
         <%If UCase(Request.Form("Validated") = "VALIDATED") Then%>
    is no longer a true statement.

    Code:
    <script Language="Javascript">
        
       function DoSubmit()
        {
    		
    		if(frmMain.name.value=="")
    		{
    			window.alert("Your Name is required before submission");
    		}
    
    
    		else
                   {
                      frmMain.Validated.value = 'Testing';
                      frmMain.submit()
                    }
        }
        
    </script>
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    hi there ninja!

    I tried changing the value like you suggested, but also had no luck.

    Why is this so difficult?!
    I have no more options left to try...
  10. #6
  11. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12

    AH HA!


    I figured out the problem.
    Code:
    <%If UCase(Request.Form("Validated") = "VALIDATED") Then%>
    What you are doing here is setting the form value of validated equal to "VALIDATED" then taking that string and Ucasing it. You need to close the Ucase before doing the comparison. Also you should be checking if they are not equal. So here is the corrected version of the offending code.
    Code:
    <%If UCase(Request.Form("Validated")) <> "VALIDATED" Then%>
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    I appreciate ALL your help with this DefJam, but nothing seems to
    get this form mailed to either party!!!

    Your change made the form go blank once I hit the submit button.

    This is sooooo frustrating!
    I think we're missing something from the big picture here!

    Any last suggestions, before I give up?
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    Below is the updated code.
    I have suspect feelings about the two lines I have made red.
    I noticed the <form> tag is opened but not closed "</form>", could this be the culprit?
    The 2nd line in red is the line that sends the email to the respective parties from the fields at the top of the form.
    Does everything look OK here?

    Code:
    <%@ Language=VBScript %>
          <%
    	Option Explicit
    	Response.Buffer = true
    	Response.Expires = -1000
          %>
    <html>
    <head>
    <title>ESP - Certification - Multiple-Choice Questions</title>
    
    <style type="text/css">
    .button  {border-style: inset;
                border-color: #FAD2A2;
                background-color: #FAD2A2;
                width: 90px;
                text-align: center;
                font-family : Verdana;
                font-weight: bold;
                color : Black;
                font-size: 10pt;
                padding: 1px}		    
    </style>
    
    
    </head>
    
    <body bgcolor="#FFFFFF" text="#000000" vlink="#800080" topmargin="0" leftmargin="0" onload="ChangeOn()" marginheight="0" marginwidth="0" link="#0000FF" alink="#FF0000">
    
    <div id="main">
    <table width="780" border="0" cellspacing="0" cellpadding="5" height="1" align="left">
       <tr bgcolor="#FF909B"> 
        <td width="725" height="6" valign="top" bgcolor="#FF9933">
        <font face="Verdana, Arial, Helvetica, sans-serif" size="4"><b><i>CERTIFICATION</i></b></font>
        </td>
      </tr>
      <tr bgcolor="#FFBFC6" valign="middle"> 
        <td height="13" bgcolor="#FAD2A2">
        <font face="Verdana, Arial, Helvetica, sans-serif" size="4"><b><i>MULTIPLE CHOICE 
        QUESTIONS</i></b></font>
        </td>
      </tr>
      <tr> 
        <td valign="top" height="1">
    
    
    <!-- ------------ INPUT FIELDS START -------------------------------------------------------------------------------------------------- -->
    
    <!-- BELOW ARE THE 3 REQUIRED FIELDS THE USER MUST FILL IN IN ORDER TO SEND THE FORM -->
    
         <%If UCase(Request.Form("Validated")) <> "VALIDATED" Then%>
    
         <form method="POST" action="<%= Request.ServerVariables("Script_Name")%>" name="frmMain">
         <input type="hidden" name="Validated" id="Validated" value="" />
    
            <input TYPE="hidden" NAME="frmMain" VALUE="0">
            <font face="Verdana, Arial, Helvetica, sans-serif" size="3">Please enter your name and the email address of yourself and your manager.</font>
            <br>
            <br>
    
    <!-- 1ST FIELD IS THE USERS FULL NAME ---------------------------------------------------------------------------------------------- -->  
        <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Name</font>
          <font size="1">
            <br>
            <input type="text" name="name" size="30" style="font-family: Verdana; font-size: 10px">
            <br>
          </font>
        </font><br><br>
    
    <!-- 2ND FIELD IS THE USERS EMAIL ADDRESS --------------------------------------------------------------------------------------- -->
        <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Your Email</font>
          <font size="1">
            <br>
            <input type="text" name="email" size="30" style="font-family: Verdana; font-size: 10px">
            <br>
          </font>
        </font><br><br>
    
    <!-- 3RD FIELD IS THE USERS MANAGERS EMAIL ADDRESS ------------------------------------------------------------------------- -->
        <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Managers Email</font>
          <font size="1">
            <br>
            <input type="text" name="manager" size="30" style="font-family: Verdana; font-size: 10px">
            <br>
          </font>
        </font><br><br>
    
    
    <!-- ONCE THE USER HITS THE SUBMIT BUTTON AT THE BOTTOM OF THE PAGE, THE FORM SHOULD BE SENT
    TO THE EMAIL ADDRESSES THE USER INPUT IN THE ABOVE 2 FIELDS-->
    
    <!-- ------------ INPUT FIELDS END ------------------------------------------------------------------------------------------------------ -->
    
    <!-- ------------ BODY OF FORM START ------------------------------------------------------------------------------------------------- -->
    
      </font></span><font size="2"><span style="font-family: Verdana"><b>1. A Sales 
      Competitor Analysis allows you to:</b><br>
      </span></font><span lang="en-us"><font size="2">
      <span style="font-family: Verdana"><input type="radio" value="V1" name="R1">a) 
      Forecast future business<br>
      </span></font><span style="font-size: 12.0pt; font-family: Times New Roman">
      <font size="2"><span style="font-family: Verdana">
      <input type="radio" name="R1" value="V2">b) Talk negatively about your 
      competitors<br>
      <input type="radio" name="R1" value="V3">c) Identify where needs are likely to 
      be found<br>
      <input type="radio" name="R1" value="V4">d) Position your products<br>
       </span></font></span></span></p>
      <p class="MsoBodyText"><font size="2" face="Verdana"><b>2. Which of the 
      following is least important in determining how to position your 
      products/service?</b><br>
      </font><font face="Verdana"><input type="radio" name="R2" value="V1"><span lang="en-us"><font size="2">a)
      </font></span><font size="2">Identify those areas where you are strong and the 
      competitor is weak.<br>
      </font><input type="radio" name="R2" value="V2"><span lang="en-us"><font size="2">b)
      </font></span><font size="2">Identify the customerís needs and how they are 
      currently being met.<br>
      </font><input type="radio" name="R2" value="V3"><span lang="en-us"><font size="2">c)
      </font></span><font size="2">Identify those areas in which you can 
      differentiate yourself from the competition.<br>
      </font></font><span style="font-size: 12.0pt; font-family: Verdana">
      <input type="radio" name="R2" value="V4"></span><span style="font-family: Verdana"><span lang="en-us"><font size="2">d)
      </font></span><font size="2">Identify the decision-makers within the 
      customerís institute.<br>
       </font></span></p>
    
    <!-- ------------ BODY OF FORM END ---------------------------------------------------------------------------------------------------- -->
    
    <!-- ------------ SUBMIT BUTTON START ----------------------------------------------------------------------------------------------- -->
    
    <div align="center">
      <a href="java script:DoSubmit()" class="button" style="text-decoration: none">
        <font size="1">SUBMIT</font>
      </a>
    </div>
    
    <!-- ------------ SUBMIT BUTTON END -------------------------------------------------------------------------------------------------- -->
    
    
    <%else SendEmailMessage()%>
        
             </td>
          </table>
        </td>
      </tr>
    </table>
    </div>
    </body>
    </html>
    <%End If%>
    
    <!-- ------------ SEND MAIL CODE START ---------------------------------------------------------------------------------------------- -->
    
    <% 
    	Sub SendEmailMessage()	
    
    		Dim objMail
    		Dim strBody
    		
    		Set objMail= CreateObject("CDONTS.Newmail")
    		
    		strBody = "<HTML>"
    		strBody = strBody &"<HEAD>"
    		strBody = strBody &"<STYLE>TD{FONT-SIZE:x-small;FONT-FAMILY:Arial}.B {font-weight:700;}.BL {font-weight:700;FONT-SIZE:small;}</STYLE>"
    		strBody = strBody & "</HEAD><BODY>"
    		strBody = strBody & "<TABLE WIDTH='100%' CELLPADDING='0'>"
    		strBody = strBody & "<tr><td> </td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong><h4>ESP Certification Results</h4></strong>" & chr(10)
    		strBody = strBody & "</td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong>Name: </strong>" & Request.Form("name") & chr(10)
    		strBody = strBody & "</td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong>Email: </strong>" & Request.Form("email") & chr(10)
    		strBody = strBody & "</td></tr>"
    		
    		strBody = strBody & " "
    		strBody = strBody & "</TABLE>"
    		strBody = strBody & "</BODY>"
    
    				
    		objMail.BodyFormat = 0'HTML
    		objMail.Body = strBody
    		
    		objMail.MailFormat = 0'Mime format
    		objMail.Importance = 2'High
    
    		objMail.From = "ESP User" 
    		objMail.To = Request.Form("manager") & ", " & Request.Form("name") & "<" & Request.Form("email") & ">"
    		objMail.Subject = "ESP User Certification Results"		
    		
    		objMail.Send
    		
    		Set objMail = Nothing
    	 
    	End Sub 
    %>
    
    <!-- ------------ SEND MAIL CODE END ------------------------------------------------------------------------------------------------- -->
    
    <!-- ------------ ERROR POP-UP START ------------------------------------------------------------------------------------------------- -->
    
    <script Language="Javascript">
        
       function DoSubmit()
        {
    		
    		if(frmMain.name.value=="")
    		{
    			window.alert("Your Name is required before submission");
    		}
    
    
    		else
                   {
                      frmMain.Validated.value = 'Validated';
                      frmMain.submit()
                    }
        }
        
    </script>
    
    <!-- ------------ ERROR POP-UP END ---------------------------------------------------------------------------------------------------- -->
  16. #9
  17. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    Don't give up you almost have it.

    Basicly you just need to clean up a few things. I'm at school right now so I don't really have the ablity to do much work with your code. But just looking it over I spotted this (actually I spotted it last time but just forgot to update it for you).
    Code:
    <%else SendEmailMessage()%>
             </td>
          </table>
        </td>
      </tr>
    </table>
    </div>
    </body>
    </html>
    <%End If%>
    You need to have the else code be after all of you closing tags other wise they will not be displayed until else is true. Also it does appear that you forgot your closing form tag so that too will need to be put into the above code.

    I'm not going to be much help to you with the actual sending of emails as I have never done it before. I do have one suggestion though, why don't you try sending just a staic email don't try anything fancy just see if you can get it to work with a static message and email address. If you can get it to send then you can try to make it all snazzy with dynamic bits and such.

    Anyway here is the corrected bit of code.
    Code:
             </td>
          </table>
        </td>
      </tr>
    </table>
    </div>
    </form> <!-- closing form tag -->
    </body>
    </html>
    <%else SendEmailMessage()%> 'by moving this here all the html is closed correctly
    <%End If%>
    Code:
    <% 
    	Sub SendEmailMessage()	
    
    		Dim objMail
    		Dim strBody
    		Response.write("We have made it into the email sub<br>Let's check the address that we are sending to...")
    		Response.write(Request.Form("manager") & ", " & Request.Form("name") & "<" & Request.Form("email") & ">")
    		Reponse.write("well does this look correct?")
    Try putting those changes in see what happens. If I get a chance today I'll look over everything in depth (maybe while I'm at work ). Good luck and don't give up.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    PROGRESS DEFJAM!!!

    Below is what I get after I hit submit:
    Code:
    We have made it into the email sub
    Let's check the address that we are sending to... manager@dtgrafx.com, user@dtgrafx.com 
    Microsoft VBScript runtime error '800a01f4' 
    
    Variable is undefined: 'Reponse' 
    
    /rsoamericas/esp/html/8_Cert/Cert_1.asp, line 625
    I've changed your code a bit to return the appropriate email addresses. Unfortunately nothing gets emailed to them.

    Code:
    Response.write(Request.Form("manager") & ", " & Request.Form("email"))
    Thanks for not giving up on me man...
    Last edited by dtgrafx; May 6th, 2003 at 03:12 PM.
  20. #11
  21. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    Code:
    We have made it into the email sub
    Let's check the address that we are sending to... manager@dtgrafx.com, user@dtgrafx.com 
    Microsoft VBScript runtime error '800a01f4' 
    
    Variable is undefined: 'Reponse' 
    
    /rsoamericas/esp/html/8_Cert/Cert_1.asp, line 625
    Well it looks like my amazing typing skills have caused an error.
    I corrected my typo so the code should run correctly now.
    Code:
    <% 
    	Sub SendEmailMessage()	
    
    		Dim objMail
    		Dim strBody
    		Response.write("We have made it into the email sub<br>Let's check the address that we are sending to...")
    		Response.write(Request.Form("manager") & ", " & Request.Form("email"))
    		Response.write("well does this look correct?")
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    you see what this thing is doing to me!
    I can't even spot a syntax error... sheesh

    I'll let you know how it goes in a few.



    It's ok now!

    So how do I get the answers the user checked off in the form to get emailed to the addresses input by the user at the top of the form?

    That question is the bane of my existance right about now
    Last edited by dtgrafx; May 7th, 2003 at 12:13 PM.
  24. #13
  25. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    Just request the form object that you want the value for. Play with this code and see what you can figure out.

    Code:
    Dim strQ1
    Dim strQ2
    Dim strMessage
    
    strQ1 = Request.form("R1")
    strQ2 = Request.form("R2")
    
    Select Case strQ1
      Case "V1"
        strQ1 = "A"
      Case "V2"
        strQ1 = "B"
      Case "V3"
        strQ1 = "C"
    End Select
    
    strMessage = "On question 1 " & Request.form("name") & "gave an answer of:  " & strQ1
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    great!

    but, does this code go imediatley after the Sub SendEmailMessage stuff?

    Thanks for everything DefJam!
  28. #15
  29. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    Originally posted by dtgrafx
    great!

    but, does this code go imediatley after the Sub SendEmailMessage stuff?

    Thanks for everything DefJam!
    The code was more for just showing you how to get a value from a radio button more than anything else. But if you wanted to try to use it it would have to go inside the email sub and before the command that sends the email.

    Code:
    <% 
    	Sub SendEmailMessage()	
    
    Dim strQ1
    Dim strQ2
    
    strQ1 = Request.form("R1")
    strQ2 = Request.form("R2")
    
    Select Case strQ1
      Case "V1"
        strQ1 = "A"
      Case "V2"
        strQ1 = "B"
      Case "V3"
        strQ1 = "C"
      'Etc... Etc...
    End Select
    
    Select Case strQ2
      Case "V1"
        strQ1 = "A"
      Case "V2"
        strQ1 = "B"
      Case "V3"
        strQ1 = "C"
      'Etc... Etc...
    End Select
    
    		Dim objMail
    		Dim strBody
    		
    		Set objMail= CreateObject("CDONTS.Newmail")
    		
    		strBody = "<HTML>"
    		strBody = strBody &"<HEAD>"
    		strBody = strBody &"<STYLE>TD{FONT-SIZE:x-small;FONT-FAMILY:Arial}.B {font-weight:700;}.BL {font-weight:700;FONT-SIZE:small;}</STYLE>"
    		strBody = strBody & "</HEAD><BODY>"
    		strBody = strBody & "<TABLE WIDTH='100%' CELLPADDING='0'>"
    		strBody = strBody & "<tr><td> </td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong><h4>ESP Certification Results</h4></strong>" & chr(10)
    		strBody = strBody & "</td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong>Name: </strong>" & Request.Form("name") & chr(10)
    		strBody = strBody & "</td></tr>"
    		strBody = strBody & "<tr><td>"
    		strBody = StrBody & "<strong>Email: </strong>" & Request.Form("email") & chr(10)
    		strBody = strBody & "</td></tr>"
    		
    		strBody = strBody & " "
    		strBody = strBody & "</TABLE>"
    'Answer to questions
    		strBody = strBody & "On question 1 " & Request.form("name") & "gave an answer of:  " & strQ1 " & "<BR>"
    strBody = strBody & "On question 2 " & Request.form("name") & "gave an answer of:  " & strQ2 " & "<BR>"
    
    
    'End answers to questions
    		strBody = strBody & "</BODY>"
    
    				
    		objMail.BodyFormat = 0'HTML
    		objMail.Body = strBody
    		
    		objMail.MailFormat = 0'Mime format
    		objMail.Importance = 2'High
    
    		objMail.From = "ESP User" 
    		objMail.To = Request.Form("manager") & ", " & Request.Form("name") & "<" & Request.Form("email") & ">"
    		objMail.Subject = "ESP User Certification Results"		
    		
    		objMail.Send
    		
    		Set objMail = Nothing
    	 
    	End Sub 
    %>
    All the code I just added is more or less for a quick example I'm sure that using a for next loop and an array would be cleaner and more fucntional but this will have to do for now. If your only going to have 2 or 3 questions having a select case for each one is not a big deal but if your going to have say 25 questions then it's going to start to become a pain.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo