Hi,
I need help - this has officially gotten beyond me, I think.
I have a form that's dynamically created through vbscript (it has to be that way... one form, many course choices, many different questions for each course), and need it to validate that all multiple-choice answers are filled in (default values are unfortunately not an option). Here are the basic facts:
Test browser/system: Firefox 12.0, Windows 7 64-bit
Symptom: When I hit the submit button, the form goes through, even if I didn't answer anything.
What it should do: If there are any radio-button questions in the form, they must all be filled in.
Errors: When I hit submit, after it mistakenly goes through, and I look at the error console, I see the error message, "document[frmName] is undefined"
Notes that are probably not relevant but I'll include them anyway:
- I'm testing this on my test server (localhost/insertvirtualnamehere/) before I put this into production. This is where the problems are occurring. Obviously, I can't put them on the production server until it's fixed on localhost first.
- The validate function is dynamically generated in vbscript, based on the same table that creates the questions. New lines in the function are created with vbNewLine.
Barebones code with a few example questions, that the vbScript returns is as follows:
Many thanks!
Katie
I need help - this has officially gotten beyond me, I think.
I have a form that's dynamically created through vbscript (it has to be that way... one form, many course choices, many different questions for each course), and need it to validate that all multiple-choice answers are filled in (default values are unfortunately not an option). Here are the basic facts:
Test browser/system: Firefox 12.0, Windows 7 64-bit
Symptom: When I hit the submit button, the form goes through, even if I didn't answer anything.
What it should do: If there are any radio-button questions in the form, they must all be filled in.
Errors: When I hit submit, after it mistakenly goes through, and I look at the error console, I see the error message, "document[frmName] is undefined"
Notes that are probably not relevant but I'll include them anyway:
- I'm testing this on my test server (localhost/insertvirtualnamehere/) before I put this into production. This is where the problems are occurring. Obviously, I can't put them on the production server until it's fixed on localhost first.
- The validate function is dynamically generated in vbscript, based on the same table that creates the questions. New lines in the function are created with vbNewLine.
Barebones code with a few example questions, that the vbScript returns is as follows:
Code:
<?xml version="1.0" encoding="windows-1252"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html[/URL] xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<script type="text/javascript">
<!--
var invalids = "!%&*()-+,';\"\\"
function getRadioVal(radioObj){
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
// -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Insert Title here</title><link href="stylesheets/style.css" rel="stylesheet" type="text/css" /><link href="stylesheets/dotcomstyle.css" rel="stylesheet" type="text/css" /><link rel="icon" type="image/gif" href="images/icon.gif">
<link rel="stylesheet" href="stylesheets/forms.css" type="text/css" />
<style type="text/css">
</style>
<script type="text/javascript">
<!--
function checkRadio (frmName, rbGroupName) {
var radios = document[frmName].elements[rbGroupName];
for (var i=0; i <radios.length; i++) {
if (radios[i].checked) {
return true;
}
}
return false;
}
function validate()
{
if (!checkRadio("evalform","EvalCtrl387"))
{
alert("You must answer all Yes/No and 1/2/3/4/5 questions. Please double-check all of the answers and try again");
return false;
}
if (!checkRadio("evalform","EvalCtrl388"))
{
alert("You must answer all Yes/No and 1/2/3/4/5 questions. Please double-check all of the answers and try again");
return false;
}
if (!checkRadio("evalform","EvalCtrl389"))
{
alert("You must answer all Yes/No and 1/2/3/4/5 questions. Please double-check all of the answers and try again");
return false;
}
if (!checkRadio("evalform","EvalCtrl400"))
{
alert("You must answer all Yes/No and 1/2/3/4/5 questions. Please double-check all of the answers and try again");
return false;
}
}
// -->
</script>
</head>
<body>
<div id="container">
<div class="section">
<h1>Insert name of page here</h1>
<h2>Insert name of class here</h2>
<p style="font-size:1.05em;font-weight:bold;">Please complete the form below to evaluate this session.</p>
</div>
<div class="section">
<form id="evalform" action="evalcert_evalquestions.asp" method="post" onsubmit="return validate();">
<input type="hidden" name="evalcontentid" value="2" />
<input type="hidden" name="classid" value="528" />
<input type="hidden" name="evaltype" value="session" />
<div class="minorcategory">
<div class="head">At the end of this program, I was able to:</div>
<div class="question">
<div class="text">Identify your facilities bylaws.</div>
<div class="answer">
<div><input type="radio" name="EvalCtrl387" value="5" />5 - Strongly agree</div>
<div><input type="radio" name="EvalCtrl387" value="4" />4 - Agree</div>
<div><input type="radio" name="EvalCtrl387" value="3" />3 - Neutral</div>
<div><input type="radio" name="EvalCtrl387" value="2" />2 - Disagree</div>
<div><input type="radio" name="EvalCtrl387" value="1" />1 - Strongly Disagree</div>
</div>
</div>
<div class="question">
<div class="text">Identify who sets, defines, writes and updates the bylaws.</div>
<div class="answer">
<div><input type="radio" name="EvalCtrl388" value="5" />5 - Strongly agree</div>
<div><input type="radio" name="EvalCtrl388" value="4" />4 - Agree</div>
<div><input type="radio" name="EvalCtrl388" value="3" />3 - Neutral</div>
<div><input type="radio" name="EvalCtrl388" value="2" />2 - Disagree</div>
<div><input type="radio" name="EvalCtrl388" value="1" />1 - Strongly Disagree</div>
</div>
</div>
<div class="question">
<div class="text">Identify wording, definitions and differences of the bylaws.</div>
<div class="answer">
<div><input type="radio" name="EvalCtrl389" value="5" />5 - Strongly agree</div>
<div><input type="radio" name="EvalCtrl389" value="4" />4 - Agree</div>
<div><input type="radio" name="EvalCtrl389" value="3" />3 - Neutral</div>
<div><input type="radio" name="EvalCtrl389" value="2" />2 - Disagree</div>
<div><input type="radio" name="EvalCtrl389" value="1" />1 - Strongly Disagree</div>
</div>
</div>
</div>
<div class="minorcategory">
<div class="question">
<div class="text">Did you as a participant notice any bias that was not previously disclosed in this program? </div>
<div class="answer">
<div><input type="radio" name="EvalCtrl400" value="1" />Yes</div>
<div><input type="radio" name="EvalCtrl400" value="0" />No</div>
</div>
</div>
<div class="question">
<div class="text">If yes, please describe who was biased and how.</div>
<div class="answer">
<div><textarea name="EvalCtrl401" cols="40" rows="5"></textarea></div>
</div>
</div>
</div>
<div class="lblstandout">
Click "submit" below to complete the evaluation.<br /><input type="hidden" name="evalform" value="submit" /><input type="image" src="images/button_submit_nls.gif" alt="Submit" />
</div>
</form></div>
</body>
</html>
Many thanks!
Katie