Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.