Skip to main content
Participant
June 22, 2009
Question

Form Fields returning undefined (ASP)

  • June 22, 2009
  • 2 replies
  • 1546 views

I put together a simple form with 4 text fields.  I used DW CS3 code to validate the required fields.  On submit, the form is processed by a second file that emails the results to me.  All my testing works perfectly.

So I put the form online.  When I test online it works perfectly.

It appears 10+ people have attempted to fill in the form.  But the form seems to only return undefined.

So I added a hidden field to collect all http headers to see if that might give me a clue. Testing works perfectly but from clients all I get in undefined even in the hidden field.

SO THE REAL QUESTION IS:  what can cause the passing of undefined field values?

This topic has been closed for replies.

2 replies

Participant
June 24, 2009

After extensive frustration and testing, I found the bug in some other piece of ajax code that was submitting this form instead of another.  The code above works fine.  Sorry for the interruption!

David_Powers
Inspiring
June 22, 2009

SO THE REAL QUESTION IS:  what can cause the passing of undefined field values?

No, the real question is what does your code look like?

Participant
June 22, 2009

Lauange: ASP

here is the simple four field form with a script  to validate required fields

<script type="text/javascript">
<!--
function MM_validateForm_v1() { //v4.0 + my own
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors1='',args1=MM_validateForm_v1.arguments;
    for (i=0; i<(args1.length-2); i+=3) { test=args1[i+2]; val=document.getElementById(args1);
      if (val) { nm=val.name; if ((val=val.value)!="" && (nm != val) && (val != "null") && (val != "undefined")) {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors1+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors1+='- '+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 (num<min || max<num) errors1+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors1 += '- '+nm+' is required.\n'; }
    } if (errors1) alert('The following error(s) occurred:\n'+errors1);
    document.MM_returnValue_ = (errors1 == '');
} }

//-->
</script>

...

<form action="RFC_process_Test.asp" method="post" name="GetInfo_Form" onSubmit="submitForm(this);return false;" style="padding-left:7px;">
  <span class="TopNorm">Full Name*</span><br />
<input name="Name" type="text" id="Name" size="20">
  <br><br>

  <span class="TopNorm">Phone*</span><br /><input name="Phone" type="text" id="Phone" size="20">
  <br><br>

  <span class="TopNorm">Email*</span><br /><input name="Email" type="text" id="Email" size="20">
  <br>
<br>
<span class="TopNorm">Website</span><br /><input name="Website" type="text" size="20">
<br>
<br><input name="browser_info" type="hidden" value="<%=Request.ServerVariables("ALL_HTTP")%>" />
  
<input name="Submit" type="submit" id="Submit" onClick="MM_validateForm_v1('Name','','R','Phone','','R','Email','','RisEmail');return document.MM_returnValue_" value="Submit">
<br>
<br>
</form>

***************************************************************************************************

Next is the processing page

ASP

<%

//cheep check to see if form field name has a good value before writing a cookie
if (String(Request.Form("Name")) != "" && String(Request.Form("Name")) != "undefined" && String(Request.Form("Name")) != "null"   ) {

  Response.Cookies("RFC")("Name") = String(Request.Form("Name"));
  Response.Cookies("RFC").Expires = DateCookieExpires();

} // end if "" check
%>

<%
var myMail
var iConf;
function sendMail(fromWho, toWho, Subject, Body, Sender, ReplyTo, hCode) {
myMail = Server.CreateObject("CDO.Message");
iConf = Server.CreateObject("cdo.configuration");
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.MyServer.com"
    iConf.Fields.Update();
myMail.Configuration = iConf;
myMail.fields("urn:schemas:mailheader:X-CustomHeader") = hCode;

myMail.fields.update();
myMail.From = fromWho;
myMail.To = toWho;
myMail.Sender = Sender;
myMail.ReplyTo = ReplyTo;
myMail.Subject = Subject;
myMail.HTMLBody = Body;

myMail.Send();
myMail = "";
iConf = "";
} // end sendMail


//Application Variables
var  fromWho = "SpecialEmail@MyServer.com";
var  toWho = "SpecialEmail@MyServer.com";//
var  Subject = "Request for Consultation";
var  Body = "";
var  Sender = "SpecialEmail@MyServer.com";
var  ReplyTo = "SpecialEmail@MyServer.com";
var  hCode = "DA_3|4|2";

%>
<%
Body = "<body><table width='300' border='0' cellspacing='5' cellpadding='3'>  <tr>    <td>Name</td>    <td>"+ String(Request.Form("Name"))  +"</td>  </tr>  <tr>    <td>Phone</td>    <td>"+ String(Request.Form("Phone"))  +"</td>  </tr>  <tr>    <td>Email</td>    <td>"+ String(Request.Form("Email"))  +"</td>  </tr>  <tr>    <td>Website</td>    <td>"+ String(Request.Form("Website"))  +"<br /><br />"+ String(Request.Form("browser_info"))  +"</td>  </tr></table><BR><BR>Please contact the client ASAP and then Reply to this email with an update.</body>";
%>
<%
//Quick Send an email to Admin: tell about agent Sign-up
sendMail (fromWho, toWho, Subject, Body, Sender, ReplyTo, hCode);
%>

***********************************************************************************************

When I get the Body in the email from what appear to be clients, all the form fields are undefined including browser_info..

David_Powers
Inspiring
June 23, 2009

Sorry, ASP is a mystery to me, but I have added the language to the subject line in the hope that someone familiar with ASP will come along to help.