View Single Post
Old 12-27-2012, 04:20 PM   PM User | #2
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
You have a couple options:

1) Ajax

You can use Ajax to onChange(this.value) of the manufacturer select, query your database with "WHERE `manufacturer`= 'value.passed.to.js.function'". Then populating your second dropdown with the return results.

2) Preload every list.

This is the option I would use. If I'm a user on your site and I have to wait X seconds every time I want to see a new list of models, I'm not happy.

I would use PHP to query your database for (unfortunately) your entire table (unless you know you don't need a few rows) for the `id`, `manufacturer`, and `model` columns (unless you need more).

Using those results, I would print them out into a javascript array and use the onChange() function of the manufacturer select to call for the respective array, which would populate the model select.

Quote:
Originally Posted by 367
when submit button is clicked it should lead to page of model, like this: index.php?p=view&m=shop&id=<certain_id>
Code:
<form method="get" action="index.php?p=view&m=shop">
<select name="id">
<option value="mysql.id">mysql.model</option>
TFlan is offline   Reply With Quote