First off my problem: I want to populate drop down boxes based on what the user has picked. I know very little JS and i've always just coded everything in php/sql.
Secondly, I know you can't run a PHP snippet based on a user's input. The only way is to resubmit the page using a JS script off the OnChange().
I've google the hell out of this and found some mediocre explanations. Figured i'd try TWW last resort.
I'll try to keep the code minimal. my first SQL query fill outs of the first box:
$sql = "SELECT carID, carName FROM car ORDER BY carGrossPower";
This is assigned to a variable (myCarID) and (carName) which in turn sets the options. This part works fine. I can get this to work. I'd like the second the drop down box populate the tires based on the car model chosen.
$sqlTyres = "SELECT * FROM tires2cars LEFT JOIN tires ON (ttTireID = carID) WHERE ttCarID = '".$val['myCarID']."'";
That code sets to another variable. My option boxes look something like this:
<select name="cars" class="form" style="width:200px" onchange="thisiswhereimstuck"> <option value=""> Select Cars</option> {html_options options=$CarName selected=$myCarID </select>
my tires code would be similar.
<select name="cars" class="form" style="width:200px" onchange="thisiswhereimstuck"> <option value=""> Select Tires</option> {html_options options=$myTires selected=$myTiredID </select>
Any insight would be helpful.
[Edited on October 14, 2009 at 8:50 AM. Reason : s]10/14/2009 8:49:12 AM |