Plan out your page
4 sections...my example would be for purchasing a car...
1. the html page that shows the form (ei:the 12 questions)
2. validation script (is the form filled out correctly?)
3. "crunching" script (take the data provided and produce an answer)
4. display results (usually a new webpage, but can be on the same page)
Page1 (home_page.htm)
<html><head><title>Sales Associate</title>
<script ="javascript" src="validation.
js"></script>
<body>
<form name = "yourchoices" method="post">
What color do you want?
<input name="choice1" value="Blue" type="radio"><br>
<input name="choice1" value="Red" type="radio"><br>
<input name="choice1" value="Black" type="radio"><br>
<input name="choice1" value="Green" type="radio"><br>
<br>
What average MPG are you looking for?
<input name="choice2" value="0-10" type="radio"><br>
<input name="choice2" value="11-20" type="radio"><br>
<input name="choice2" value="21-40" type="radio"><br>
<input name="choice2" value="41+" type="radio"><br>
<br>
What type or style car are you looking for?
<input name="choice3" value="Sedan" type="radio"><br>
<input name="choice3" value="SUV" type="radio"><br>
<input name="choice3" value="Compact" type="radio"><br>
<input name="choice3" value="Anything that runs" type="radio"><br>
<br>
<input value="Submit" onclick="valadate();" type="button">
</body></html>
Page2 (valadation.
js) (ok so I mixed steps 2 and 3 together here...)
function valadate()
{
var a= document.yourchoices.choice1; var option1= -1
var b= document.yourchoices.choice2; var option2= -1
var c= document.yourchoices.choice3; var option3= -1
for (i=0;i<a.length;i++)
{if(a[i].checked)
{option1=a[i].value}}
if (option1 == -1) {
alert("You must select a radio button from the first set of options");
return false;}
for (j=0;j<b.length;j++)
{if(b[j].checked)
{option2=b[j].value}}
if (option2 == -1) {
alert("You must select a radio button from the second set of options");
return false;}
for (k=0;k<c.length;k++)
{if(c[k].checked)
{option3=c[k].value}}
if (option3 == -1) {
alert("You must select a radio button from the third set of options");
return false;}
4. Here is where I myself have problems... this is where a person would normal write :
if (option1="red" && option2="21-40" && option3="compact")
alert ("You need a 4-cylinder Ford Escort")
and then continue with every possible combination... (about 41? i think)
if there is an easier way... i would like to know as well :D
Hope to help...
In a world of give and take, take all you can and you die with nothing. Give all you can and you die with honor.