User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » OnChange (PHP/JS help) Page [1]  
Novicane
All American
15413 Posts
user info
edit post

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

Ernie
All American
45943 Posts
user info
edit post

http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/

10/14/2009 9:18:18 AM

 Message Boards » Tech Talk » OnChange (PHP/JS help) Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.