![]() |
Dynamic Car Make, Model, Year, Battery dropdown form
Hello,
I recenly started with a dropdown form that get car Make, Model and Year. I have a database called "Vehicles" with 3 Tables "year", "make", "model". When you select a year the optionfield make is comming up and you can select a make but after selecting for example "Toyota" it is stuck on Please Wait... Can somebody tell me what I am missing or what is wrong with this script? This is my Index.php: Code:
<html>Code:
$(document).ready(function() {PHP Code:
Any help would be very welcome:) Thanks in advance Kind Regards |
The reason why it "gets stuck" on loading is because I don't see any real Ajax happening, and you have no code to extract your list of make-related models.
This script is not finished, that is your problem. Nothing is wrong, albeit it's not functioning the way you think it is |
Hello again,
I got it working now but getting stuck with something else I want to create. This are my two scripts now: index.php PHP Code:
PHP Code:
Make = Volvo Model = XC90 Year = 2013 "You selected a Volvo XC90 from 2013" So that part is working allright!:) The second thing I want to create is when you select the fields as above you also echo the Battery that belongs to that combination. I have another table called "battery" in my database for example this record: Make = Volvo Model = XC90 Year = 2013 Battery = XXX How can I echo "battery" too that belongs to the selected fields of the dropdown? Something like this: "You selected a Volvo XC90 from 2013 and you should buy the XXX battery" I got it this far but I'm not that good in php so if somebody could help me here that would be great:) Thanks in advance |
DO you have any type of identifier that corresponds between the model of the car and the battery that works on it? What I mean by that is, is there some way of matching the model to the battery? You would need a column in the database with the batteries that match up to this if you are finding the battery in the database and don't know it off hand. If you either give a screenshot or text based layout of the table and it's columns (at least important ones to find it), it would be easier to assist you.
As an example if you do not wish to do that, try something like this: Say I have the following combination: Make: Volvo Model: XC90 Year: 2013 Now I need to find the battery, and for the example we'll just say it's 246 (I don't know much about automotive things). Since you said you have a table for the batteries, I'm assuming it's going to have at least a column with the name in it. You need some other column that holds a value that you can match it on (ex. serial, the make/model/year combination, or something that is unique to that battery). All you need to do is perform a query that will select that battery from the table with the given information. Example 1: PHP Code:
PHP Code:
|
Hi,
Thanks for the reply:) I almost got it working but still got one problem... My script is like this now: PHP Code:
How can I edit the last function that it only will show the battery from Volvo - XC90 - 2013 and not all the batteries from 2013? Thanks in advance:) Edit = My database is like this: Database = vehicles Tables - id - make - model - year - battery(accu) |
a 2nd WHERE in your query, well its HAVING
something like PHP Code:
|
I got it all working!
People that are interested here is the code: Index.php PHP Code:
PHP Code:
|
Hi!
I have a nearly similar project, I'm working on. Let's say my database based on Joepiooo's has : - id - make - model - year - battery(accu) -fuel -color How can I echo "fuel" and "color" from my down narrowed result. I tried it with a standard echo command: PHP Code:
It should display like this: Volvo XC90 2009 accu (+extra data from table, after filtering through dropdown) 70 liter silver Can someone help me? PS: Sorry English is not my native language |
| All times are GMT +1. The time now is 04:21 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.