V
vindictive27
I created the following form for the company intranet. All seems to
work well, with the exception of the submission. After submitting,
all of the answers come through in the e-mail EXCEPT the calculated
answers which were figured and placed on form elements by my
javascript. It appears that the answers placed by the javascript are
not being picked up by the ASP variables on submission. Any ideas?
<html>
<head>
<script language="JavaScript" src="good-date.js"></script>
<link rel="stylesheet" type="text/css" href="good-date.css">
<script type="text/javascript">
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode :
event.which ?
event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i+
+)
if (field == field.form.elements)
break;
i = (i + 1) % field.form.elements.length;
field.form.elements.focus();
return false;
}
else
return true;
}
function calcSub1() {
var x = document.getElementById('Text6').value;
var y = x - 2;
var obj = document.getElementById('Text7');
obj.value = y;
}
function calcTot1() {
var a = document.getElementById('Text8').value;
var b = document.getElementById('Text7').value;
var c = a * b;
var obj2 = document.getElementById('Text9');
obj2.value = c;
}
function calcTot2() {
var d = document.getElementById('Text11').value;
var e = document.getElementById('Text9').value;
var f = d * e
var obj3 = document.getElementById('Text10');
obj3.value = f;
}
function calcTot3() {
var g = document.getElementById('Text12').value;
var h = g - 100
var obj4 = document.getElementById('Text13');
obj4.value = h;
var i = h * .505
var obj5 = document.getElementById('Text14');
obj5.value = i;
}
function calcTot4() {
var j = document.getElementById('Text16').value;
var k = document.getElementById('Text19').value;
var l = k * 25
var m = j * l
var obj6 = document.getElementById('Text17');
obj6.value = m;
}
function calcTot5() {
var n = document.getElementById('Text10').value;
var o = document.getElementById('Text14').value;
var p = document.getElementById('Text15').value;
var q = document.getElementById('Text17').value;
var r = parseInt(n) + parseInt(o) + parseInt(p) +
parseInt(q);
var obj7 = document.getElementById('Text18');
obj7.value = r;
}
</script>
<title><%= FORM_NAME %></title>
<link rel="stylesheet" type="text/css" href="forms.css">
<style type="text/css">
<!--
TD {
font-family: Arial;
font-size: 9pt;
}
-->
</style>
</head>
<body<!-- #include file="bodytag.asp" -->>
<!-- #include file="bodyheader2.asp" -->
<script language="VBScript">
dim validation
function MyForm_OnSubmit
validation = True
If validation = True Then
MyForm_OnSubmit = True
Else
MyForm_OnSubmit = False
End if
end Function
</script>
<%
Const FORM_NAME = "Network Mileage Form"
Dim INSTRUCTIONS
INSTRUCTIONS = "Please fill out each section completely and
accurately."
' setup common variables
Dim strLoginID
strLoginID = Replace(Request.ServerVariables("LOGON_USER"), "NA
\",
"")
Dim strMailTo, strCopyTo
strMailTo = "(e-mail address removed)"
strCopyTo = Request.Form("tbxCc")
CcSender = Request.Form("CcSender")
If CcSender = "yes" Then
If strCopyTo = "" Then
strCopyTo = strLoginID & "@email.com"
Else
strCopyTo = strCopyTo & ", " & strLoginID &
"@email.com"
End if
End if
'questions
Const QUESTION1 = "Company Acknowledgment Number: "
Const QUESTION2 = "Customer Address: "
Const QUESTION3 = "Date of Travel: "
Const QUESTION4 = "Your Invoice Number: "
Const QUESTION5 = "Total Travel Hours (Round Trip): "
Const QUESTION6 = "Subtotal: "
Const QUESTION7 = "Number of Men: "
Const QUESTION8 = "Total Billable Hours: "
Const QUESTION14 = "Warranty Labor Rate:"
Const QUESTION9 = "Total for Labor: "
Const QUESTION10 = "Total Number of Miles (Round Trip): "
Const QUESTION11 = "Total Number of Billable Miles: "
Const QUESTION12 = "Total for Mileage: "
Const QUESTION13 = "Hotel Invoices (Enter Total Amount): "
Const QUESTION15 = "Number of Men:"
Const QUESTION18 = "Number of Days:"
Const QUESTION16 = "Total Per Diem Amount:"
Const QUESTION17 = "Total Amount of Claim:"
'answers
Answer1 = Request.Form("Answer1")
Answer2 = Request.Form("Answer2")
Answer3 = Request.Form("Answer3")
Answer4 = Request.Form("Answer4")
Answer5 = Request.Form("Answer5")
Answer6 = Request.Form("Answer6")
Answer7 = Request.Form("Answer7")
Answer8 = Request.Form("Answer8")
Answer9 = Request.Form("Answer9")
Answer10 = Request.Form("Answer10")
Answer11 = Request.Form("Answer11")
Answer12 = Request.Form("Answer12")
Answer13 = Request.Form("Answer13")
Answer14 = Request.Form("Answer14")
Answer15 = Request.Form("Answer15")
Answer16 = Request.Form("Answer16")
Answer17 = Request.Form("Answer17")
Answer18 = Request.Form("Answer18")
If Answer1 <> "" Then ' send email
' create the email body
Dim strBody
strBody = "To: " & strMailTo & VbCrLf & _
"From: " & strLoginID &
"@email.com" & VbCrLf & _
"Date: " & Date & " Time: "
& Time & VbCrLf & VbCrLf & _
FORM_NAME & VbCrLf & _
"==================================" & VbCrLf & _
QUESTION1 & Answer1 & VbCrLf &
_
QUESTION2 & Answer2 & VbCrLf &
_
QUESTION3 & Answer3 & VbCrLf &
_
QUESTION4 & Answer4 & VbCrLf &
_
QUESTION5 & Answer5 & VbCrLf &
_
QUESTION6 & Answer6 & VbCrLf &
_
QUESTION7 & Answer7 & VbCrLf &
_
QUESTION8 & Answer8 & VbCrLf &
_
QUESTION14 & Answer14 & VbCrLf
& _
QUESTION9 & Answer9 & VbCrLf &
_
QUESTION10 & Answer10 & VbCrLf
& _
QUESTION11 & Answer11 & VbCrLf
& _
QUESTION12 & Answer12 & VbCrLf
& _
QUESTION13 & Answer13 & VbCrLf
& _
QUESTION15 & Answer15 & VbCrLf
& _
QUESTION18 & Answer18 & VbCrLf
& _
QUESTION16 & Answer16 & VbCrLf
& _
QUESTION17 & Answer17
' send the email message
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
With objMail
.To = strMailTo
.From = strLoginID & "@email.com"
.Subject = FORM_NAME
.TextBody = strBody
.Send
End With
Set objMail = Nothing
' after the form is sent, redirect to the Thank You
page.
Response.Redirect "thankyou.asp"
End If
%>
<br><center><h3><%= FORM_NAME %></center></h3>
<!-- Don't change - this table is used to control format of the page
--
<table width="600" cellpadding="5" cellspacing="0" align="center"
style="{border-width: 1px; border-color: gray; border-style:
solid }"><tr><td bgcolor="#E5E5E5">
<form name="MyForm" action="<%=
Request.ServerVariables("Script_Name")
%>" method="post">
<table>
<tr><td>To:</td><td><input type="text" name="tbxTo" size="30"
onkeypress="return handleEnter(this, event)"></td></tr>
<tr><td>Cc:</td><td><input type="text" name="tbxCc" size="30"
onkeypress="return handleEnter(this, event)" ID="Text1"></
td><td><input type="checkbox" name="CcSender" value="yes"
ID="Checkbox1">Send a copy to myself</td></tr>
<tr><td>From:</td><td><%= LCase(strLoginID) %>@email.com</td></
tr>
<tr><td>Subject:</td><td><%= FORM_NAME %></td></tr>
<tr><td>Date:</td><td><%= Date %></td></tr>
<tr><td>Time:</td><td><%= Time %></td></tr>
</table><br>
<table width="100%" ID="Table2">
<tr><td><%= QUESTION1 %></td><td><input type="text" name="Answer1"
size="30" onkeypress="return handleEnter(this, event)" ID="Text2"></
td></tr>
<tr><td><%= QUESTION2 %></td><td><textarea name="Answer2" rows="4"
cols="40" ID="Textarea1"></textarea></td></tr>
<tr><td><%= QUESTION3 %></td><td><input type="text" name="Answer3"
size="8" onkeypress="return handleEnter(this, event)"
ID="Text4"><input type=button value="select"
onclick="displayDatePicker('Answer3', this);"></td></tr>
<tr><td><%= QUESTION4 %></td><td><input type="text" name="Answer4"
size="30" onkeypress="return handleEnter(this, event)" ID="Text5"></
td></tr>
<tr><td><%= QUESTION5 %></td><td><input type="text" name="Answer5"
size="30" onkeypress="return handleEnter(this, event)" ID="Text6"
onBlur="calcSub1()";></td></tr>
<tr><td><%= QUESTION6 %></td><td><input type="text" name="Answer6"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text7"></td></tr>
<tr><td><%= QUESTION7 %></td><td><input type="text" name="Answer7"
size="30" onkeypress="return handleEnter(this, event)" ID="Text8"
onBlur="calcTot1()";></td></tr>
<tr><td><%= QUESTION8 %></td><td><input type="text" name="Answer8"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text9"></td></tr>
<tr><td><%= QUESTION14 %></td><td><input type="text" name="Answer14"
size="30" onkeypress="return handleEnter(this, event)" ID="Text11"
onBlur="calcTot2()";></td></tr>
<tr><td><%= QUESTION9 %></td><td><input type="text" name="Answer9"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text10"></td></tr>
<tr><td><hr></td></tr>
<tr><td><%= QUESTION10 %></td><td><input type="text" name="Answer10"
size="30" onkeypress="return handleEnter(this, event)" ID="Text12"
onBlur="calcTot3()";></td></tr>
<tr><td><%= QUESTION11 %></td><td><input type="text" name="Answer11"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text13"></td></tr>
<tr><td><%= QUESTION12 %></td><td><input type="text" name="Answer12"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text14"></td></tr>
<tr><td><hr></td></tr>
<tr><td><%= QUESTION13 %></td><td><input type="text" name="Answer13"
size="30" onkeypress="return handleEnter(this, event)" ID="Text15"></
td></tr>
<tr><td align="left" nowrap><small><b>Please fax receipts to the
Network Department at XXX-XXX-XXXX.</b></small></td></tr>
<tr><td><hr></td></tr>
<tr><td align="left" nowrap><u><b>Per Diem - Must Have Overnight Stay
to Claim:</b></u></td></tr>
<tr><td><%= QUESTION15 %></td><td><input type="text" name="Answer15"
size="30" onkeypress="return handleEnter(this, event)" ID="Text16"></
td></tr>
<tr><td><%= QUESTION18 %></td><td><input type="text" name="Answer18"
size="30" onkeypress="return handleEnter(this, event)" ID="Text19"
onBlur="calcTot4();calcTot5()";></td></tr>
<tr><td><%= QUESTION16 %></td><td><input type="text" name="Answer16"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text17"></td></tr>
<tr><td><hr></td></tr>
<tr><td><%= QUESTION17 %></td><td><input type="text" name="Answer17"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text18"></td></tr>
</table>
<br><br><hr><br>
<table align="center">
<tr>
<td align="center"><input type="reset"
value="Clear
Form"> <input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<!-- this table is used to control format of the page -->
</td></tr></table><br><br>
<!-- #include file="footer.asp" -->
</body>
</html>
work well, with the exception of the submission. After submitting,
all of the answers come through in the e-mail EXCEPT the calculated
answers which were figured and placed on form elements by my
javascript. It appears that the answers placed by the javascript are
not being picked up by the ASP variables on submission. Any ideas?
<html>
<head>
<script language="JavaScript" src="good-date.js"></script>
<link rel="stylesheet" type="text/css" href="good-date.css">
<script type="text/javascript">
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode :
event.which ?
event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i+
+)
if (field == field.form.elements)
break;
i = (i + 1) % field.form.elements.length;
field.form.elements.focus();
return false;
}
else
return true;
}
function calcSub1() {
var x = document.getElementById('Text6').value;
var y = x - 2;
var obj = document.getElementById('Text7');
obj.value = y;
}
function calcTot1() {
var a = document.getElementById('Text8').value;
var b = document.getElementById('Text7').value;
var c = a * b;
var obj2 = document.getElementById('Text9');
obj2.value = c;
}
function calcTot2() {
var d = document.getElementById('Text11').value;
var e = document.getElementById('Text9').value;
var f = d * e
var obj3 = document.getElementById('Text10');
obj3.value = f;
}
function calcTot3() {
var g = document.getElementById('Text12').value;
var h = g - 100
var obj4 = document.getElementById('Text13');
obj4.value = h;
var i = h * .505
var obj5 = document.getElementById('Text14');
obj5.value = i;
}
function calcTot4() {
var j = document.getElementById('Text16').value;
var k = document.getElementById('Text19').value;
var l = k * 25
var m = j * l
var obj6 = document.getElementById('Text17');
obj6.value = m;
}
function calcTot5() {
var n = document.getElementById('Text10').value;
var o = document.getElementById('Text14').value;
var p = document.getElementById('Text15').value;
var q = document.getElementById('Text17').value;
var r = parseInt(n) + parseInt(o) + parseInt(p) +
parseInt(q);
var obj7 = document.getElementById('Text18');
obj7.value = r;
}
</script>
<title><%= FORM_NAME %></title>
<link rel="stylesheet" type="text/css" href="forms.css">
<style type="text/css">
<!--
TD {
font-family: Arial;
font-size: 9pt;
}
-->
</style>
</head>
<body<!-- #include file="bodytag.asp" -->>
<!-- #include file="bodyheader2.asp" -->
<script language="VBScript">
dim validation
function MyForm_OnSubmit
validation = True
If validation = True Then
MyForm_OnSubmit = True
Else
MyForm_OnSubmit = False
End if
end Function
</script>
<%
Const FORM_NAME = "Network Mileage Form"
Dim INSTRUCTIONS
INSTRUCTIONS = "Please fill out each section completely and
accurately."
' setup common variables
Dim strLoginID
strLoginID = Replace(Request.ServerVariables("LOGON_USER"), "NA
\",
"")
Dim strMailTo, strCopyTo
strMailTo = "(e-mail address removed)"
strCopyTo = Request.Form("tbxCc")
CcSender = Request.Form("CcSender")
If CcSender = "yes" Then
If strCopyTo = "" Then
strCopyTo = strLoginID & "@email.com"
Else
strCopyTo = strCopyTo & ", " & strLoginID &
"@email.com"
End if
End if
'questions
Const QUESTION1 = "Company Acknowledgment Number: "
Const QUESTION2 = "Customer Address: "
Const QUESTION3 = "Date of Travel: "
Const QUESTION4 = "Your Invoice Number: "
Const QUESTION5 = "Total Travel Hours (Round Trip): "
Const QUESTION6 = "Subtotal: "
Const QUESTION7 = "Number of Men: "
Const QUESTION8 = "Total Billable Hours: "
Const QUESTION14 = "Warranty Labor Rate:"
Const QUESTION9 = "Total for Labor: "
Const QUESTION10 = "Total Number of Miles (Round Trip): "
Const QUESTION11 = "Total Number of Billable Miles: "
Const QUESTION12 = "Total for Mileage: "
Const QUESTION13 = "Hotel Invoices (Enter Total Amount): "
Const QUESTION15 = "Number of Men:"
Const QUESTION18 = "Number of Days:"
Const QUESTION16 = "Total Per Diem Amount:"
Const QUESTION17 = "Total Amount of Claim:"
'answers
Answer1 = Request.Form("Answer1")
Answer2 = Request.Form("Answer2")
Answer3 = Request.Form("Answer3")
Answer4 = Request.Form("Answer4")
Answer5 = Request.Form("Answer5")
Answer6 = Request.Form("Answer6")
Answer7 = Request.Form("Answer7")
Answer8 = Request.Form("Answer8")
Answer9 = Request.Form("Answer9")
Answer10 = Request.Form("Answer10")
Answer11 = Request.Form("Answer11")
Answer12 = Request.Form("Answer12")
Answer13 = Request.Form("Answer13")
Answer14 = Request.Form("Answer14")
Answer15 = Request.Form("Answer15")
Answer16 = Request.Form("Answer16")
Answer17 = Request.Form("Answer17")
Answer18 = Request.Form("Answer18")
If Answer1 <> "" Then ' send email
' create the email body
Dim strBody
strBody = "To: " & strMailTo & VbCrLf & _
"From: " & strLoginID &
"@email.com" & VbCrLf & _
"Date: " & Date & " Time: "
& Time & VbCrLf & VbCrLf & _
FORM_NAME & VbCrLf & _
"==================================" & VbCrLf & _
QUESTION1 & Answer1 & VbCrLf &
_
QUESTION2 & Answer2 & VbCrLf &
_
QUESTION3 & Answer3 & VbCrLf &
_
QUESTION4 & Answer4 & VbCrLf &
_
QUESTION5 & Answer5 & VbCrLf &
_
QUESTION6 & Answer6 & VbCrLf &
_
QUESTION7 & Answer7 & VbCrLf &
_
QUESTION8 & Answer8 & VbCrLf &
_
QUESTION14 & Answer14 & VbCrLf
& _
QUESTION9 & Answer9 & VbCrLf &
_
QUESTION10 & Answer10 & VbCrLf
& _
QUESTION11 & Answer11 & VbCrLf
& _
QUESTION12 & Answer12 & VbCrLf
& _
QUESTION13 & Answer13 & VbCrLf
& _
QUESTION15 & Answer15 & VbCrLf
& _
QUESTION18 & Answer18 & VbCrLf
& _
QUESTION16 & Answer16 & VbCrLf
& _
QUESTION17 & Answer17
' send the email message
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
With objMail
.To = strMailTo
.From = strLoginID & "@email.com"
.Subject = FORM_NAME
.TextBody = strBody
.Send
End With
Set objMail = Nothing
' after the form is sent, redirect to the Thank You
page.
Response.Redirect "thankyou.asp"
End If
%>
<br><center><h3><%= FORM_NAME %></center></h3>
<!-- Don't change - this table is used to control format of the page
--
<table width="600" cellpadding="5" cellspacing="0" align="center"
style="{border-width: 1px; border-color: gray; border-style:
solid }"><tr><td bgcolor="#E5E5E5">
<form name="MyForm" action="<%=
Request.ServerVariables("Script_Name")
%>" method="post">
<table>
<tr><td>To:</td><td><input type="text" name="tbxTo" size="30"
onkeypress="return handleEnter(this, event)"></td></tr>
<tr><td>Cc:</td><td><input type="text" name="tbxCc" size="30"
onkeypress="return handleEnter(this, event)" ID="Text1"></
td><td><input type="checkbox" name="CcSender" value="yes"
ID="Checkbox1">Send a copy to myself</td></tr>
<tr><td>From:</td><td><%= LCase(strLoginID) %>@email.com</td></
tr>
<tr><td>Subject:</td><td><%= FORM_NAME %></td></tr>
<tr><td>Date:</td><td><%= Date %></td></tr>
<tr><td>Time:</td><td><%= Time %></td></tr>
</table><br>
<table width="100%" ID="Table2">
<tr><td><%= QUESTION1 %></td><td><input type="text" name="Answer1"
size="30" onkeypress="return handleEnter(this, event)" ID="Text2"></
td></tr>
<tr><td><%= QUESTION2 %></td><td><textarea name="Answer2" rows="4"
cols="40" ID="Textarea1"></textarea></td></tr>
<tr><td><%= QUESTION3 %></td><td><input type="text" name="Answer3"
size="8" onkeypress="return handleEnter(this, event)"
ID="Text4"><input type=button value="select"
onclick="displayDatePicker('Answer3', this);"></td></tr>
<tr><td><%= QUESTION4 %></td><td><input type="text" name="Answer4"
size="30" onkeypress="return handleEnter(this, event)" ID="Text5"></
td></tr>
<tr><td><%= QUESTION5 %></td><td><input type="text" name="Answer5"
size="30" onkeypress="return handleEnter(this, event)" ID="Text6"
onBlur="calcSub1()";></td></tr>
<tr><td><%= QUESTION6 %></td><td><input type="text" name="Answer6"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text7"></td></tr>
<tr><td><%= QUESTION7 %></td><td><input type="text" name="Answer7"
size="30" onkeypress="return handleEnter(this, event)" ID="Text8"
onBlur="calcTot1()";></td></tr>
<tr><td><%= QUESTION8 %></td><td><input type="text" name="Answer8"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text9"></td></tr>
<tr><td><%= QUESTION14 %></td><td><input type="text" name="Answer14"
size="30" onkeypress="return handleEnter(this, event)" ID="Text11"
onBlur="calcTot2()";></td></tr>
<tr><td><%= QUESTION9 %></td><td><input type="text" name="Answer9"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text10"></td></tr>
<tr><td><hr></td></tr>
<tr><td><%= QUESTION10 %></td><td><input type="text" name="Answer10"
size="30" onkeypress="return handleEnter(this, event)" ID="Text12"
onBlur="calcTot3()";></td></tr>
<tr><td><%= QUESTION11 %></td><td><input type="text" name="Answer11"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text13"></td></tr>
<tr><td><%= QUESTION12 %></td><td><input type="text" name="Answer12"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text14"></td></tr>
<tr><td><hr></td></tr>
<tr><td><%= QUESTION13 %></td><td><input type="text" name="Answer13"
size="30" onkeypress="return handleEnter(this, event)" ID="Text15"></
td></tr>
<tr><td align="left" nowrap><small><b>Please fax receipts to the
Network Department at XXX-XXX-XXXX.</b></small></td></tr>
<tr><td><hr></td></tr>
<tr><td align="left" nowrap><u><b>Per Diem - Must Have Overnight Stay
to Claim:</b></u></td></tr>
<tr><td><%= QUESTION15 %></td><td><input type="text" name="Answer15"
size="30" onkeypress="return handleEnter(this, event)" ID="Text16"></
td></tr>
<tr><td><%= QUESTION18 %></td><td><input type="text" name="Answer18"
size="30" onkeypress="return handleEnter(this, event)" ID="Text19"
onBlur="calcTot4();calcTot5()";></td></tr>
<tr><td><%= QUESTION16 %></td><td><input type="text" name="Answer16"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text17"></td></tr>
<tr><td><hr></td></tr>
<tr><td><%= QUESTION17 %></td><td><input type="text" name="Answer17"
size="30" disabled="disabled" onkeypress="return handleEnter(this,
event)" ID="Text18"></td></tr>
</table>
<br><br><hr><br>
<table align="center">
<tr>
<td align="center"><input type="reset"
value="Clear
Form"> <input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<!-- this table is used to control format of the page -->
</td></tr></table><br><br>
<!-- #include file="footer.asp" -->
</body>
</html>