Jump to content

Dynamic Page


steelerman99

Recommended Posts

Hello again!

 

I have a page with a drop down box at the top with 4 options.  I have 4 drop down boxes further down the page with data that correspond to the choices in the first one (ie- the top box is a category and the 4 boxes further down the page correspond to those categories.)

 

What i want to do is have the user select something from the top box, then enable one of the 4 drop downs down the page and disable the rest (or show/hide.  whichever works).  For example:  if i choose option #2 in the top box, i want box #2 to be enabled and the others disabled (or show/hide).

 

 

Can anyone tell me how i can accomplish this?  I'm using php if that makes a difference.

 

Thanks again!!

Link to comment
https://forums.phpfreaks.com/topic/69699-dynamic-page/
Share on other sites

Edit:

 

The above post is wrong.

 

 

I only have one drop down box at the bottom of the page. 

 

What i want to do:  when the user clicks one of the options in the box at the top of the page, i want the box at the bottom of the page with data that corresponds to the top.

 

So for example.  The top box choices are fruit and colors.  If the user clicks on colors, box2 at the bottom will have choices of red, green, blue.  If the user clicks on fruit at the top, the box will change to apple, banana, grape.

 

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/69699-dynamic-page/#findComment-350211
Share on other sites

Just taking a stab at your second one. It's crude but it seems to work. Is this what you're looking for?  ;D

 

<html>
<body>
<form action="NoName.php" method="post" name="form1">
<div>
<select name="list">
<option value="red"> red</option>
<option value="blue"> blue</option>
<option value="green"> green</option>
</select></div>
<div><input type="submit" value="submit" name="submit"></div>
</form>
<?php
// if submit
if (isset($_POST['submit'])){
// get variable
$list = $_POST['list'];
//if conditionals
if ($list == "red") {  
// you can either include the form action here or just the drop down box div or just the select code
 echo '<form action="page.php" method="post" name="form2">
<div><select name="list_one">
	<option value="apple"> apple</option>
	<option value="orange"> orange</option>
	<option value="banana"> banana</option>
</select></div>
<div><input type="button" value="submit" name="submit"></div>
</form>';
}

if ($list == "blue") { 
 echo '<form action="page.php" method="post" name="form3">
<div><select name="list_one">
	<option value="Ford"> Ford</option>
	<option value="Toyota"> Toyota</option>
	<option value="Porsche"> Porsche</option>
</select></div>
<div><input type="button" value="submit" name="submit"></div>
</form>';
   }
//.... whatever other options you need.	 
}
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/69699-dynamic-page/#findComment-350884
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.