jkelly061597
asked on
Multi-section form processing
I am creating a web survey that will display questions a few at a time, changing the few questions based on previous answers. Once all relevent questions have been answered I need to e-mail the results. Is CGI the way to do it?
Jeff
Jeff
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, but please give me another 24 hours: i have a little dead-end for tomorrow.
ASKER
No problem...
Hello back,
i'm sorry to admit i didn't take into account that there are a couple of problems with submitting mail forms: a form with a "mailto:" action does popup a confirm dialog, AND - once the mail has been sent - there's no easy way to automatically redirect the user to a "tank you" page.
You could get rid of the confirm popup, in NN4 only, by signing your script; if you are interested in this, i could give you the additional code needed, but i cannot help on the script signing itself, since i've never done it.
This all is NOT a problem with CGI, and i won't submit an answer unless you explicitely ask, because i myself would not consider this as a *professional* implementation of a mail send - so it seems i just solved to parameter passing task.
This said, you'll find here a couple of sample Html files... any question is welcome.
You might want to maximize the browser window before the cut-and-paste work.
Regards.
--/ [step0.htm] /--
<HTML>
<HEAD>
<TITLE>Step 0</TITLE>
<SCRIPT LANGUAGE="Javascript"><!--
function toSubmit(aForm) {
if(!aForm.r0[0].checked && !aForm.r0[1].checked) {
self.alert("Need a choice");
return false;
}
return true;
}
// --></SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="step1.htm" METHOD="GET"
onSubmit="return toSubmit(this)">
<INPUT TYPE="radio" NAME="r0" VALUE="0">Radio r0[0]<BR>
<INPUT TYPE="radio" NAME="r0" VALUE="1">Radio r0[1]<BR>
<INPUT TYPE="submit" VALUE="Next">
</FORM>
</BODY>
</HTML>
--//--
--/ [step1.htm] /--
<HTML>
<HEAD>
<TITLE>Step 1</TITLE>
<SCRIPT LANGUAGE="Javascript"><!--
var theR0 = getQueryVal("r0", "0"); // theR is a String
function getQueryVal(aKey, defaultVal) {
var srch = self.location.search;
var idxK = srch.indexOf(aKey + "=", 1);
if(idxK == -1 ||
(srch[idxK-1] != "?" &&
srch[idxK-1] != "&")) // no key
return defaultVal;
var idxVS = idxK + aKey.length + 1;
if(idxVS == srch.length) // no value
return defaultVal;
var idxVE = srch.indexOf("&", idxVS);
return srch.substring(idxVS, idxVE==-1 ? srch.length : idxVE)
}
function toSubmit(aForm) {
if(!aForm.r1[0].checked && !aForm.r1[1].checked) {
self.alert("Need a choice");
return false;
}
return true;
}
// --></SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="mailto:julio?subje ct=Web Survey" ENCTYPE="text/plain"
onSubmit="return toSubmit(this)">
<SCRIPT LANGUAGE="Javascript"><!--
document.writeln("<INPUT TYPE=\"hidden\" " +
"NAME=\"r0\" VALUE=\"" + theR0 + "\">");
if(theR0 == "1") {
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"0\">Radio (1-\>) r1[0]<BR>");
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"1\">Radio (1-\>) r1[1]<BR>");
}
else { // default value
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"0\">Radio (0->) r1[0]<BR>");
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"1\">Radio (0->) r1[1]<BR>");
}
// --></SCRIPT>
<INPUT TYPE="submit" VALUE="Next">
</FORM>
</BODY>
</HTML>
--//--
i'm sorry to admit i didn't take into account that there are a couple of problems with submitting mail forms: a form with a "mailto:" action does popup a confirm dialog, AND - once the mail has been sent - there's no easy way to automatically redirect the user to a "tank you" page.
You could get rid of the confirm popup, in NN4 only, by signing your script; if you are interested in this, i could give you the additional code needed, but i cannot help on the script signing itself, since i've never done it.
This all is NOT a problem with CGI, and i won't submit an answer unless you explicitely ask, because i myself would not consider this as a *professional* implementation of a mail send - so it seems i just solved to parameter passing task.
This said, you'll find here a couple of sample Html files... any question is welcome.
You might want to maximize the browser window before the cut-and-paste work.
Regards.
--/ [step0.htm] /--
<HTML>
<HEAD>
<TITLE>Step 0</TITLE>
<SCRIPT LANGUAGE="Javascript"><!--
function toSubmit(aForm) {
if(!aForm.r0[0].checked && !aForm.r0[1].checked) {
self.alert("Need a choice");
return false;
}
return true;
}
// --></SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="step1.htm" METHOD="GET"
onSubmit="return toSubmit(this)">
<INPUT TYPE="radio" NAME="r0" VALUE="0">Radio r0[0]<BR>
<INPUT TYPE="radio" NAME="r0" VALUE="1">Radio r0[1]<BR>
<INPUT TYPE="submit" VALUE="Next">
</FORM>
</BODY>
</HTML>
--//--
--/ [step1.htm] /--
<HTML>
<HEAD>
<TITLE>Step 1</TITLE>
<SCRIPT LANGUAGE="Javascript"><!--
var theR0 = getQueryVal("r0", "0"); // theR is a String
function getQueryVal(aKey, defaultVal) {
var srch = self.location.search;
var idxK = srch.indexOf(aKey + "=", 1);
if(idxK == -1 ||
(srch[idxK-1] != "?" &&
srch[idxK-1] != "&")) // no key
return defaultVal;
var idxVS = idxK + aKey.length + 1;
if(idxVS == srch.length) // no value
return defaultVal;
var idxVE = srch.indexOf("&", idxVS);
return srch.substring(idxVS, idxVE==-1 ? srch.length : idxVE)
}
function toSubmit(aForm) {
if(!aForm.r1[0].checked && !aForm.r1[1].checked) {
self.alert("Need a choice");
return false;
}
return true;
}
// --></SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="mailto:julio?subje
onSubmit="return toSubmit(this)">
<SCRIPT LANGUAGE="Javascript"><!--
document.writeln("<INPUT TYPE=\"hidden\" " +
"NAME=\"r0\" VALUE=\"" + theR0 + "\">");
if(theR0 == "1") {
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"0\">Radio (1-\>) r1[0]<BR>");
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"1\">Radio (1-\>) r1[1]<BR>");
}
else { // default value
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"0\">Radio (0->) r1[0]<BR>");
document.writeln("<INPUT TYPE=\"radio\" " +
"NAME=\"r1\" VALUE=\"1\">Radio (0->) r1[1]<BR>");
}
// --></SCRIPT>
<INPUT TYPE="submit" VALUE="Next">
</FORM>
</BODY>
</HTML>
--//--
Oops! sorry, i had already locked this question... time to bed :)
ASKER
Thanks, I'll play around with it...
ASKER