FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Making diff. options avail. change based on what is selected





johnmk
Basicly how I need this to work is there are two drop down boxes. First they will chose between a,b,c,d,e. If they choose a then on the second drop down box I only want them to be able to select a1,a2,a3,a4,a5. If they choose b then they can only see b1,b2,b3,b4,b5.


This is what is in the first dropdown box.

Code:

$selValues['john'] = "a, b, c, d, e";


These are the different lists I want it to put in the second drop down box depending on what they choose in the first.

Code:

$selValues['list1']= " a1, a2, a3, a4, a5";
$selValues['list2']= " b1, b2, b3, b4, b5";


This is how I made an attempt to make it work before posting here. Along with plently of other ways.

Code:

if ($selValues['john']=a)
{
     $chan_input = selectBuilder($selValues['$list1'] };
else if ($selValues['john']=b)
 {
     $chan_input = selectBuilder($selValues['$list2'] };



Any help would be greatly appreciated. Thanks for reading.
jmraker
Many sites do this in with javascript where your program generates some javascript code, or an ajax request when the first field changes.

If you're doing it in just PHP you might want to break the select boxes into 2 pages where the 1st one is on page 1, and after they submit it goes to make the 2nd select box based on the 1st page selection

I noticed a few syntax errors.
if ($selValues['john']=a)
should be
if ($selValues['john'] == 'a')

and
selectBuilder($selValues['$list1']
should be
selectBuilder($selValues['list1']

If they're entering the selection in a web page the form fields would be in $_REQUEST, and either $POST or $_GET
sonam
I will suggest Ajax for your needs. Here is simple tutorial
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_database

This tutorial use asp but you can simple to change for php.

Sonam
Related topics
new Nintendo Revolution
language translation utility
Web Reporting - AWSTATS
Does nobody here make the games?
the 9/11 truth
select boxes value change?
Looking for advice on making a good video game based website
Does God exist?
President Bush talks w/ Matt Lauer on Torture
Whats the best foods to eat daily???
"Sticky Keys"/Language changing
Boomcoding
Things only a Republican could believe
Guess the number of posts [Closed for Now]
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.