HTML Form processing script

John Reynolds said:
God damnit, that's too easy. I need to read this CSS book I have instead of haphazardly hacking away at it like this. But thanks again.
I find I learn a lot quicker while haphazardly hacking away at things. :) That's the whole fun right there.
 
OK, page is finished. My only issue is when I hit the submit button I now get error on page message on the status bar. Everything works fine, but I'm not sure what's generating an error.

Code:
<html>
<head>
<title>SMSG Feedback Form</title>
<style>
html, body {background-color: #f0f0f0;
margin: 0px 0px 0px 0px;}
p {font-family: "times new roman";
font-size: 11pt;
color: #0000ff;
text-align: center;}
p.1 {font-family: garamond; 
font-size: 20pt; 
text-align: center;
color: #0000ff;
font-weight: bolder;
margin: 30px;
text-align: center;}
p.2 {font-family: "times new roman"; 
font-size: 11pt;
color: #0000ff;
font-style: oblique;}
p.3 {font-family: "times new roman";
font-size: 11pt;
color: #0000ff;
text-align: center;
margin: 55px 0px 5px 10px;}
#menu {float: left;
height: 100%;
width: 200px;
background-color: #0000ff;
font-family: verdana;
font-size: 10pt;
text-align: center;
color: #ffffff;
padding: 100px 5px 5px 5px;
border-right: 1px solid black;}
textarea {background-color: transparent;}
#watermark {background-image: url(logo.png);
background-repeat: no-repeat;
background-position: center 15px;
margin-left: 200px;}
</style>
</head>
<body>
<script language="VBScript">
Function myForm_OnSubmit
Dim item, strFilePath
Dim objFSO, myFile
Dim TheForm
Dim retVal
Const ForAppending = 8
Const MaxCharacters = 500
Set TheForm = Document.forms("myform")
retVal = False
 
If Len(TheForm.feedback.value) > MaxCharacters Then
MsgBox "Your feedback is too long. Please enter a maximum of 500 characters."
Else
strFilePath = "[url="file://server/Feedback.txt"]\\server\Feedback.txt[/url]"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If NOT objFSO.FileExists(strFilePath) Then
objFSO.CreateTextFile(strFilePath)
End If
Set myFile = objFSO.OpenTextFile (strFilePath, ForAppending, True)
myFile.WriteLine("Form submitted at " & now())
For Each item In TheForm
If item.name <> "submitter" Then
	myFile.WriteLine(item.name & " : " & item.value)
End If
Next
myFile.WriteLine(vbNewLine)
myFile.Close
Set myFile = Nothing
Set objFSO = Nothing
MsgBox "Thank you for submitting feedback."
retVal = True
End If
 
myForm_OnSubmit = retVal
End Function
</script>
<div id="menu">Welcome to the SMSG Anonymous Feedback Form! You can use this form to ask questions, suggest new processes, recommend divesting activities, recognize good things that happen in the SMSG, or identify things that are not so good. Col Franz and I will be the only ones to see your inputs, and we have no way to find out who made the submission -- that's what 'anonymous' is all about. Once we have your inputs, we will take the necessary actions and report their status and closeout during following Director's Calls. Thank you for taking time to make the SMSG the best place to spend your workdays.</div>
<div id="watermark">
<p class="1">Simulator Systems Group's<br>Anonymous Feedback Form</p>
<form id="myform" method="post" onsubmit="SubmitForm()">
<p><center><textarea rows="9" cols="50" name="Feedback"></textarea><br>
<p class="2">- Feedback is limited to 500 characters in length. -</p>
<p><input name="submitter" type="submit" value="Submit Feedback"></p>
<p><input name="submitter" type="reset" value="Reset the Form"></p>
</form>
<p class="3">After clicking on the "Submit Feedback" button,<br>you will see this window:</p>
<center><img src="error.jpg"></center>
<p>Choose "Yes" to finish submitting your feedback.</p>
</div>
</body>
</html>
 
DarN said:
What does the error say? There's usually some debug info there...

It's not a pop-up window, it's just text on the status bar. No additional info and looking back over the code I'm lost as to what's causing it.
 
John Reynolds said:
It's not a pop-up window, it's just text on the status bar. No additional info and looking back over the code I'm lost as to what's causing it.
Dobleclick the warning icon.
 
DarN said:
Dobleclick the warning icon.

LOL I thought of that, but the damn ActiveX window that pops up prevents that. I hit yes or no in that window and the error goes away.

Like I said, the form works but I've made some change to cause this error since it wasn't there previously.

Edit: Disregard, I'm now convinced that it's the ActiveX window itself that's the error, but I have no choice in this since IE settings are mandated from the Powers Above me.
 
John Reynolds said:
Disregard, I'm now convinced that it's the ActiveX window itself that's the error, but I have no choice in this since IE settings are mandated from the Powers Above me.
You mean you can't change anything in the IE settings? If you can, you can set "Always show script errors" in the advanced settings. That should give you a look at the error dialog.
 
DarN said:
You mean you can't change anything in the IE settings? If you can, you can set "Always show script errors" in the advanced settings. That should give you a look at the error dialog.

Cool.

Error reads line 106, Char 1, error type mismatch: 'submitform'.
 
Somehow you've let some old code slip back into the script. You need to remove the onsubmit="SubmitForm()" from the FORM tag, as it's no longer needed. ie. change this line:
Code:
<form id="myForm" method="post" onsubmit="SubmitForm()">
to
Code:
<form id="myForm" method="post">
 
Are you sure, Diplo? I thought he had to do:

<form id="myform" method="post" onsubmit="myForm_OnSubmit"> ?

BTW, Opera's error description was somewhat easier to understand: "Reference to undefined variable: SubmitForm" :)
 
Last edited by a moderator:
DarN said:
Are you sure, Diplo? I thought he had to do:

<form id="myform" method="post" onsubmit="myForm_OnSubmit"> ?
You would think so, wouldn't you? But you didn't count on the weird vagaries of VBScript :)
Basically, client-side VB will automatically call a function if it's named in the manner formName_OnSubmit. So the function was already getting called when the form was submitted so there was no need for the function remaining (which didn't exist, anyway).
 
Back
Top