Click to See Complete Forum and Search --> : checkbox and open a new html page


Tee
01-30-2003, 03:23 PM
I have been working on this for a while and I can not seem to get it ot work.


Scenario: A user has an option of checking 4 checkboxes. The question is what are your favorite foods. pizza; hamburger; french fries; hot dogs. If the user checks pizza and hambuger and clicks submit they will get a html page that tells them all about those foods. If the user checks pizza and clicks submit they will get a html page about pizza. There is a different html page for each different combination of checks that are clicked.

Can someone please help.....

Thanks!!!

Dan Drillich
01-30-2003, 03:59 PM
Here is an example in which the form is submitted only in the case that pizza and hamburger are checked. In this case we set the form action to be iwon. Otherwise, we don't submit the form.
You have to put your logic into the check function.



<SCRIPT LANGUAGE="JavaScript">


function check()
{
if (document.food.pizza.checked && document.food.hamburger.checked) {
document.food.action = "http://www.iwon.com";
return true;
}

return false;
}


</SCRIPT>

<FORM NAME="food" onsubmit="return check();">
<b>Select the food(s):</b><br>

pizza - <input type="checkbox" name="pizza"><br><br>
hamburger - <input type="checkbox" name="hamburger"><br><br>
french fries - <input type="checkbox" name="french fries"><br><br>
hot dogs - <input type="checkbox" name="hot dogs"><br><br>
<input type="submit">

</FORM>


Cheers,
Dan