• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Second list box values changing according to selection of first list box

Hi

I have simple table that lists cars, trucks etc. I would like to put those values to list box. And I want to have another list box as well. If user selects cars, it will go to another table and read cars there and list them at second list box. If user select trucks, it will automatically select trucks from table and list them at second list box.

If you could please help, it will be great.

Thanks
0
hasozduru
Asked:
hasozduru
1 Solution
 
str_kaniCommented:
list1 (for selecting car or trucks)

list2 (for showing the cars..)

list3 (for showing the trucks..) right?

you can do that using only one list box,!

when the user select something in the list1, fetch all data needed from the     db and fill it in the list2.  


<?php

?>
<select name="sel1">
<option value="car">Car</option>
<option value="truck">Truck</option>
</select>

<select name="sel2">
<?php
if(isset($_POST['sel1']))
{
$selected_option=$_POST['sel'];
if ($selected_option=="car")
{
//select query for car
}elseif ($selected_option=="truck")
{
//select query for truck
}

}
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
?>
<option value="<?php $row[0]?>"><?php $row[0]?></option>
<?Php
}
?>
</select>
0
 
hasozduruAuthor Commented:
This example did not help me. I am looking for something like at www.easyjet.com site. Please visit and select "from" list box and see how "to" list box changes according to "from" one.

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now