Contact page with acknowledgement page

I have been trying to figure out how to get my contact page once filled out to show an acknowledgement page that has the users input information ( first name, last name, email, number, and comment made) along with a message.
redrose43311Asked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
i don't see any validation code, no wonder its not validating :)

you should be able to use the code below to validate all of the fields and make sure they're filled out. This uses straight-forward javascript (this seems like a learning exercise and I don't want to throw too much at you. just a FYI, using jQuery to validate would be easier as would HTML5). This form posts itself and when it does, it'll write out the data posted to the screen. you'll notice I changed the server side language to vbscript, typically server side coding is done in vbscript, and client side is done in javascript. It's not a hard and fast rule, you can code in either, but the industry standard is typically done this way.

<%@language=vbscript %>

<%
if Request.Form("button") = "Submit" then    '-- submit button was pressed
     Response.Write Your data looks like this:<br/><br/>" _
               "First Name: " & Request.Form("fname") & "<br/><br/>" _
               "Last Name: " & Request.Form("lname") & "<br/><br/>" _
               "Email:" & Request.Form("email") & "<br/><br/>" _
               "Phone Number" & Request.Form("pnumber") & "<br/><br/>" _
               "Comments:<br>" & Request.Form("comment")
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>contactform</title>

<script  type="text/javascript">
     function validateForm() {
         var frm = document.form;  //-- gets the form object and assigns it to a local variable
         var validate = true;   // we check this variable at the end, if it's true, we submit
         var msg = '';

          if( frm.fname == '' ) {
             msg = 'Please fill out your first name.';
             validate = false;
             frm.fname.focus();     //-- set the focus to the invalid field
         } else if( frm.lname == '' ) {
             msg = 'Please fill out your last name.';
             validate = false;
             frm.lname.focus();     //-- set the focus to the invalid field
         } else if( frm.email == '' ) {
             msg = 'Please fill out your email address.';
             validate = false;
             frm.email.focus();     //-- set the focus to the invalid field
         } else if( frm.pnumber == '' ) {
             msg = 'Please fill out your phone number.';
             validate = false;
             frm.pnumber.focus();     //-- set the focus to the invalid field
         } else if( frm.comment == '' ) {
             msg = 'Please fill out the comments field.';
             validate = false;
             frm.comment.focus();     //-- set the focus to the invalid field
         } 

         if( ! validate )
            alert( msg );

         return validate;     // if this is false the form will not submit
     }
</script>
</head>

<body onsubmit="return validateForm();">
<form action="samepage.asp" method="post">
  <table width="481" border="2">
    <tr>
      <th width="183" scope="row">First name</th>
      <td width="280"><input type="text" name="fname" id="fname" /></td>
    </tr>
    <tr>
      <th scope="row"><label for="lname">Last Name</label></th>
      <td><input type="text" name="lname" id="lname" /></td>
    </tr>
    <tr>
      <th scope="row"><label for="email">Email Address</label></th>
      <td><input type="text" name="email" id="email" /></td>
    </tr>
    <tr>
      <th scope="row"><label for="pnumber">Phone Number</label></th>
      <td><input type="text" name="pnumber" id="pnumber" /></td>
    </tr>
    <tr>
      <th scope="row">Reason for Contact</th>
      <td><textarea name="comment" id="comment"></textarea></td>
    </tr>
    <tr>
      <th height="56" scope="row">&nbsp;</th>
      <td><input type="submit" name="button" id="button" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>

Open in new window


be sure to set the forms action to the name of the page in order for it to work. You can also put your confirmation page name there and use the same logic I used, except writing it to a screen, you'll probably want to save it to the database.

Hope this helps get you in the right direction
0
 
Dave BaldwinFixer of ProblemsCommented:
A contact form page needs to be submitted to a page that is programmed in a server side language like PHP or ASP to receive it and do something with it.  What language are you using on your web server?
0
 
redrose43311Author Commented:
It is to be written in ASP, I have been using Dreamweaver to write the codes for the contact form. I am new to all of this so kinda confused.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Dave BaldwinFixer of ProblemsCommented:
This page shows you the basics: http://www.w3schools.com/asp/asp_inputforms.asp
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
show us what you've gotten so far with coding and ask specific questions on what you're having problems and I'm absolutely positive someone on here will help you out.

you may also want to consider adding the ASP zone
0
 
redrose43311Author Commented:
Ok I am so lost here, Now for some reason I can not get the information to validate nor load to a new page with the users input information showing. here is the code I am working with,


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>contactform</title>
</head>

<body>
<form action="" method="post">
  <table width="481" border="2">
    <tr>
      <th width="183" scope="row">First name</th>
      <td width="280"><input type="text" name="fname" id="fname" /></td>
    </tr>
    <tr>
      <th scope="row"><label for="lname">Last Name</label></th>
      <td><input type="text" name="lname" id="lname" /></td>
    </tr>
    <tr>
      <th scope="row"><label for="email">Email Address</label></th>
      <td><input type="text" name="email" id="email" /></td>
    </tr>
    <tr>
      <th scope="row"><label for="pnumber">Phone Number</label></th>
      <td><input type="text" name="pnumber" id="pnumber" /></td>
    </tr>
    <tr>
      <th scope="row">Reason for Contact</th>
      <td><textarea name="comment" id="comment"></textarea></td>
    </tr>
    <tr>
      <th height="56" scope="row">&nbsp;</th>
      <td><input type="submit" name="button" id="button" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>
0
 
Dave BaldwinFixer of ProblemsCommented:
This line <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> is not needed for the code that you have.  There is no javascript on that page.

And this line <form action="" method="post"> tells the form to POST to itself.  To POST it to another page, you have put that page in the 'action' attribute like...
<form action="nextpage.asp" method="post">

Open in new window

Please read the page I linked... http://www.w3schools.com/asp/asp_inputforms.asp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.