• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Please tell me why this form won't submit

I wrote a page that contains a form.  The first part shows when the page loads, then the user presses continue and the second part of the form shows up.  The form gets validated on submit - then I want it to submit after it's validated.  But the submit is not happening.  Please help!

link:  http://local.colite.com/web/kelly/ht/register.asp
0
kellybelly
Asked:
kellybelly
  • 8
  • 3
  • 3
  • +2
1 Solution
 
kellybellyAuthor Commented:
feel free to submit test data
0
 
ryanscoolCommented:
Im just starting to learn my way around javascript. What I think the problem is, is that you are not submiting the form. I did a quick search on google and found some code for using a link to submit a form. Here is the form code I found:
<a href="javascript:document.the_form.submit();">Submit</a>

My thought is that you need to include "the_form.submit();" in the cont() function. I'm not exactly sure on this and I hope someone else will come in and make a comment.

Cheers,
Ryan
0
 
kellybellyAuthor Commented:
thanks ryan.  THe submit call is included in the validation script at the end, but I think the syntax  may be wrong.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ZylochCommented:
1) Change this:
function cont()
{
      //alert("called");
      document.all.part1.style.display = 'none';
      document.all.part2.style.visibility = 'visible';
};
to
function cont()
{
      //alert("called");
   if (document.getElementById) {
      document.getElementById("part1").style.display = 'none';
      document.getElementById("part2").style.visibility = 'visible';
   }
   else if (document.all) {
      document.all.part1.style.display = 'none';
      document.all.part2.style.visibility = 'visible';
   }
   else if (document.layers) {
      document.layers[part2].visibility = 'show';
   }
}

2) Add a name attribute to your tables just in case for NN4:
<table id="part1" name="part1" border="0" cellpadding="0" cellspacing="0">
<table id="part2" name="part2" cellpadding="0" cellspacing="0" border="0" style="visibility: hidden";>

3) In MM_validateForm(), change this:
if (errors) alert('The following error(s) occurred:\n'+errors);
  if (errors == '') {
        alert('called')
        document.forms['register'].submit();
      } else {
      alert('else called')
      document.all.part1.style.display = 'block';
      document.all.cont.style.display = 'none';
      };
  document.MM_returnValue = (errors == '');

to

if (errors) {alert('The following error(s) occurred:\n'+errors);}
  if (errors == '') {
        //alert('called')
        document.forms['register'].submit();
      }
      } else {
      //alert('else called')
      if (document.getElementById) {
         document.getElementById("part1").style.display='block';
         document.getElementById("cont").style.display='none';
      } else if (document.all) {
      document.all.part1.style.display = 'block';
      document.all.cont.style.display = 'none';
      } else if (document.layers) {
        document.layers['part1'].visibility = 'show';
        document.layers['cont'].visibility = 'none';
      }
      };
      document.MM_returnValue = (errors == '');

The above is to make your code more browser compatible. In the end, however, the problem was that your <form> tag had the same ID and name, which somehow seemed to mess things up.

Change your name to something different and change the document.forms['FORMNAME'].submit(); accordingly and it should b e fine.

Regards,
${Zyloch}
0
 
VincentPugliaCommented:
Hi,

  it submits as is if you make this one change:

<a href="#"     // instead of "javascript:"
 onClick="MM_validateForm('fName','','R','lName','','R','company','','R','email','','RisEmail','password','','R');return document.MM_returnValue;alert(document.MM_returnValue)">Submit to Hometown</a>

also, it wouldn't hurt to kill the return statement above (I added the alert so you'd see)
1) you never get it -- the form has already submitted and is on another page
2) you don't need it -- see #1 above

Vinny
0
 
ZylochCommented:
Ahh... lol. I changed that too on whim but never realized it was that that caused it. (I was wondering why you had to change the form name lol)

Regards,
${Zyloch}
0
 
VincentPugliaCommented:
Hi Zyloch,  

As someone once told me decades ago -- KISS [keep it simple, stupid]  :D

Vinny
0
 
kellybellyAuthor Commented:
I think you guys are both right - but the form is still not submitting.  Go to:

http://local.colite.com/web/kelly/ht/register.asp

and submit some test data.  I am getting an error page on submit.
0
 
VincentPugliaCommented:
hi,

  The only error it gave me was that the page could not be found, which implies either the page doesn't exist or it is spelled incorrectly.  However, it also implies the page was submitted

Vinny
0
 
kellybellyAuthor Commented:
the database didn't change, and for some reason whenever the page I get that error it's because the page didn't load all the way.  Look at the URL on the page where you are getting the error, it's the exact same as the page you were on when you submitted the info, which is exacltly how it should be.  But the second time I am getting the "page not found"
0
 
ZylochCommented:
It says:
HTTP 500 - Internal server error

which mostly likely occurred because of an error in your server-side script. Can you post your ASP code?

Regards,
${Zyloch}
0
 
kellybellyAuthor Commented:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../Connections/HT.asp" -->

<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
      response.write "submitted"
      MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>

<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) <> "") Then

  MM_editConnection = MM_HT_STRING
  MM_editTable = "brokers"
  MM_editRedirectUrl = "?msg=sent"
  MM_fieldsStr  = "fName|value|lName|value|title|value|company|value|busPhone|value|cellPhone|value|homePhone|value|busAddr1|value|busAddr2|value|busCity|value|busState|value|busZip|value|email|value|pword|value|dateCreated|value|lastAccess|value"
  MM_columnsStr = "fName|',none,''|lName|',none,''|title|',none,''|company|',none,''|busPhone|',none,''|cellPhone|',none,''|homePhone|',none,''|busAddr1|',none,''|busAddr2|',none,''|busCity|',none,''|busState|',none,''|busZip|',none,''|email|',none,''|pword|',none,''|dateCreated|',none,''|lastAccess|',none,''"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
      ' format email message
      dim message
      message = "Name:" & vbTab & vbTab & vbTab & request.queryString("fName") & " " & request.queryString("lName") & vbcrlf
      message = message & "Title:" & vbTab & vbTab & vbTab & request.queryString("title") & vbcrlf
      message = message & "Company:" & vbTab & vbTab & request.queryString("company") & vbcrlf
      message = message & "Cell:" & vbTab & vbTab & vbTab & request.queryString("cellphone") & vbcrlf
      message = message & "Work Phone:" & vbTab & vbTab & request.queryString("Busphone") & vbcrlf
      message = message & "Other Phone:" & vbTab & vbTab & request.queryString("Homephone") & vbcrlf
      message = message & "Email:" & vbTab & vbTab & request.queryString("email") & vbcrlf & vbcrlf & vbcrlf
      message = message & "To administer this new broker request <a href=" & server.mapPath("/admin/newBroker.asp") & ">Click Here</a>"
                  
      ' send email
      Set objMail = Server.CreateObject("CDONTS.NewMail")
      objMail.BodyFormat = 1
      objMail.MailFormat = 0
      objMail.To = "klwiseman@hotmail.com"
      objMail.From = request.queryString("email")
      objMail.Subject = "Broker member request from the your website (HTMortgage.net)"
      objMail.Body = message
      objMail.Send
      Set objMail = Nothing

End If
%>

<%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End if
    MM_tableValues = MM_tableValues & MM_columns(i)
    MM_dbValues = MM_dbValues & FormVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

<html>
<head>
<script language="javascript">
<!--
function compareFields(strValue,strValue2){
    return strValue == strValue2;
}
function validate(fObj){
     if(!compareFields(fObj["pword"].value,fObj["password2"].value)){
          alert("The fields do not match, please re-type");
          return false;
     }
     return true;
}

function cont()
{
     //alert("called");
   if (document.getElementById) {
      document.getElementById("part1").style.display = 'none';
      document.getElementById("part2").style.visibility = 'visible';
   }
   else if (document.all) {
     document.all.part1.style.display = 'none';
     document.all.part2.style.visibility = 'visible';
   }
   else if (document.layers) {
      document.layers[part2].visibility = 'show';
   }
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  if (errors == '') {
        //alert('called')
        document.forms['register'].submit();
      } else {
      //alert('else called')
      document.all.part1.style.display = 'block';
      document.all.cont.style.display = 'none';
      };
  document.MM_returnValue = (errors == '');
}
//-->
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1>Register to be a user of the Hometown Connect web center</h1>
<% if request.queryString("msg") <> "" then %>
<i><font size="+1" color="#990000"><b>Your information has been submitted to Hometown Mortgage.  You will be notified of your acceptance status by a Hometown representative.  Thank you for your interest</b></font></i>
<% else %>
<form METHOD="POST" name="register" id="register" action="<%=MM_editAction%>">
    <table id="part1" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td align="right">Name:</td>
            <td width="10"></td>
            <td>
                <input type="text" name="fName" value="First name" onFocus="this.value='';" size="25">
                <input type="text" name="lName" value="Last name" onFocus="this.value='';" size="50">
            *</td>
        </tr>
        <tr>
            <td align="right">Title:</td>
            <td width="10"></td>
            <td>
                <input type="text" name="title" size="25">
        </td>
        </tr>
        <tr>
            <td align="right">Company:</td>
            <td width="10"></td>
            <td>
                <input type="text" name="company" size="25">
            *</td>
        </tr>
        <tr>
            <td align="right" valign="top">Phone:</td>
            <td width="10"></td>
            <td>
                <input type="text" name="busPhone" value="Work phone" onFocus="this.value='(area)   -    '">
            *<br>
                <input type="text" name="cellPhone" value="Mobile phone" onFocus="this.value='(area)   -    '">
            <br>
                <input type="text" name="homePhone" value="Other phone" onFocus="this.value='(area)   -    '">
            <br>
        </td>
        </tr>
        <tr>
            <td align="right" valign="top">Business Address:</td>
            <td width="10"></td>
            <td>
                <input type="text" name="busAddr1" value="Line 1" onFocus="this.value='';" size="50">
            *<br>
                <input type="text" name="busAddr2" value="Line 2" onFocus="this.value='';" size="50">
            <br>
                <input type="text" name="busCity" value="City" onFocus="this.value='';" size="30">
                      <select name="busState">
                          <option value="" selected>Select one</option>
                          <option value="AL">Alabama</option>
                          <option value="AK">Alaska</option>
                          <option value="AZ">Arizona</option>
                          <option value="AR">Arkansas</option>
                          <option value="CA">California</option>
                          <option value="CO">Colorado</option>
                          <option value="CT">Connecticut</option>
                          <option value="DE">Delaware</option>
                          <option value="DC">District of Columbia</option>
                          <option value="FL">Florida</option>
                          <option value="GA">Georgia</option>
                          <option value="HI">Hawaii</option>
                          <option value="ID">Idaho</option>
                          <option value="IL">Illinois</option>
                          <option value="IN">Indiana</option>
                          <option value="IA">Iowa</option>
                          <option value="KS">Kansas</option>
                          <option value="KY">Kentucky</option>
                          <option value="LA">Louisiana</option>
                          <option value="ME">Maine</option>
                          <option value="MD">Maryland</option>
                          <option value="MA">Massachusetts</option>
                          <option value="MI">Michigan</option>
                          <option value="MN">Minnesota</option>
                          <option value="MS">Mississippi</option>
                          <option value="MO">Missouri</option>
                          <option value="MT">Montana</option>
                          <option value="NE">Nebraska</option>
                          <option value="NV">Nevada</option>
                          <option value="NH">New Hampshire</option>
                          <option value="NJ">New Jersey</option>
                          <option value="NM">New Mexico</option>
                          <option value="NY">New York</option>
                          <option value="NC">North Carolina</option>
                          <option value="ND">North Dakota</option>
                          <option value="OH">Ohio</option>
                          <option value="OK">Oklahoma</option>
                          <option value="OR">Oregon</option>
                          <option value="PA">Pennsylvania</option>
                          <option value="RI">Rhode Island</option>
                          <option value="SC">South Carolina</option>
                          <option value="SD">South Dakota</option>
                          <option value="TN">Tennessee</option>
                          <option value="TX">Texas</option>
                          <option value="UT">Utah</option>
                          <option value="VT">Vermont</option>
                          <option value="VA">Virginia</option>
                          <option value="WA">Washington</option>
                          <option value="WV">West Virginia</option>
                          <option value="WI">Wisconsin</option>
                          <option value="WY">Wyoming</option>
                          <option value="value">Other</option>
                      </select>
                <input type="text" name="busZip" value="Zip Code" onFocus="this.value='     -    ';" size="10">
        </td>
        </tr>
        <tr>
            <td valign="top">
                <div align="right">Email Address:</div>
            </td>
            <td width="10"></td>
            <td>
                <input type="text" name="email" size="50">
            *<br>
            <i><font size="-1">If you have multiple email accounts please remember which  email address you use - it will become your user name!</font></i>
            </td>
        <tr>
            <td>&nbsp;</td>
            <td width="10"></td>
            <td>&nbsp;</td>
        <tr id="cont">
            <td>&nbsp;</td>
            <td width="10"></td>
            <td><a href="#" onClick="cont();"><i><b>Continue</b></i></a></td>
    </table>
    <table id="part2" cellpadding="0" cellspacing="0" border="0" style="visibility: hidden";>
        <tr>
            <td align="right">Choose a password</td>
            <td width="10">&nbsp;</td>
            <td>
                <input type="password" name="pword" size="20">
        </td>
        <tr>
            <td align="right">Re-type password for verification:</td>
            <td width="10">&nbsp;</td>
            <td>
                <input type="password" name="password2" size="20" onChange="return validate(this.form);">
        </td>
        <tr>
            <td align="right">&nbsp;</td>
            <td width="10">&nbsp;</td>
            <td>&nbsp;</td>
        <tr>
            <td align="right">
               
                <input type="hidden" name="MM_insert" value="true">
                <input type="hidden" name="dateCreated" value="<%= date %>">
                <input type="hidden" name="lastAccess" value="<%= date %>">
        </td>
            <td width="10">&nbsp;</td>
            <td><I><B><a href="#" onClick="MM_validateForm('fName','','R','lName','','R','company','','R','email','','RisEmail','password','','R');">Submit to Hometown</a></B></I></td>
    </table>
    </form>
<% end if %>
</body>
</html>



0
 
run2004Commented:
I tried to post the data use some sample values. I am getting error message server.createobject failed. Can you please send the source code of the register.asp.

Thanks!

Run2004
0
 
kellybellyAuthor Commented:
see above post.  That is the source code.
0
 
kellybellyAuthor Commented:
OK - I am getting this error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/web/kelly/ht/register.asp, line 60

800401f3

when I check this error out it says that I do not have the IIS running SMTP email.  But I definately do have that running because I CDONTS works fine on other pages...
0
 
kellybellyAuthor Commented:
thanks for your help.  It works when I move the validation script to a 'onMouseOver' command, and put the submit on the 'onClick' event
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 8
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now