dfowler Posted November 14, 2007 Share Posted November 14, 2007 Hey, I'm trying to setup a form where certain options are hidden and depend on what your choice is to display the next question. Here is what I have so far. I could really use some help with this. index.php <?php $logo = $_POST['logo']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Project</title> <style type="text/css"> p.heading { margin:0px; font-size:18px; font-weight:bold; } </style> </head> <body><?php include('info.php'); ?> <form action="results.php" method="post"> <table align="center" width="600" style="margin-top:15px;"> <tr> <td style="border:none; border-bottom:dashed #CCCCCC 1px;"> <p class="heading">Site Type</p> <?php foreach($site_type as $value => $name) { echo '<input type="radio" name="sites" value="'.$value.'">'.$name.'<br />'; } ?> </td> </tr> <tr> <td style="border:none; border-bottom:dashed #CCCCCC 1px;"> <p class="heading">Number of Pages</p> <select name="pages"> <?php foreach($site_pages[0] as $s) { echo '<option value="'.$s.'">'.$s.'</option>'; } ?> </select> </td> </tr> <tr> <td style="border:none; border-bottom:dashed #CCCCCC 1px;"> <p class="heading">Logo</p> <select name="logo"> <?php foreach($logo_choice as $l) { echo '<option value="'.$l.'">'.$l.'</option>'; } ?> </select> <?php if($logo == 'yes') { ?> <select name="concepts"> <?php foreach($logo_con[0] as $c) { echo '<option value="'.$c.'">'.$c.'</option>'; } ?> </select> <?php } ?> </td> </tr> </table> </form> </body> </html> info.php <?php //The type of site the customer wants $site_type = array("Static", "Content Management", "eCommerce", "MySpace", "Entirely Flash"); //The number of pages the customer wants $page_row1 = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"); //The multiplier for the page they select $page_row2 = array("4","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5","2.5"); //The rate for the page they select $page_row3 = array("$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150","$150"); $site_pages = array($page_row1,$page_row2,$page_row3); //Logo Choices $logo_choice = array("yes", "no"); //Logo Concepts $logo_row1 = array("1","2","3"); //Logo Concept Prices $logo_row2 = array("600","950","1300"); $logo_con = array($logo_row1,$logo_row2); ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 14, 2007 Share Posted November 14, 2007 If you want to do this dynamically on the page without the user submitting, then you would need JavaScript for that. You could combine the JavaScript with PHP (AJAX) if the new questions are not preset. Quote Link to comment Share on other sites More sharing options...
dfowler Posted November 14, 2007 Author Share Posted November 14, 2007 Yeah, that is basically what I was looking to do. I didn't know I would need javascript. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.