Gå til innhold

Lage en søkefunksjon ved bruk av rullegardinmeny, koblet opp mot database


Anbefalte innlegg

Heisann,

 

Kjenner så vidt til PHP og MySQL, men trenger litt hjelp for å komme meg noen vei. Det jeg skal prøve og utvikle er søkt likt dette og dette.

 

Man velger bilmerke, deretter velger man modell. Når man har valgt dette, skal søkeresultatet føres opp i en tabell som dukker opp under. Den skal se slik ut:

 

 

| Motor | Årsmodell | Originaleffekt | Effektøkning | Graf | Pris |

 

 

Jeg skjønner at dette må knyttes opp mot en database. Men hvor skal jeg begynne?

Lenke til kommentar
Videoannonse
Annonse

Har laget til rullegardinen ved hjelp av JavaScript, så det har jeg kontroll på. Kommer med kode snart. :)

 

 

EDIT: Slik ser lista ut, men hvordan går jeg videre nå? Når man har valgt bilmerke og modell, skal de ulike motorene komme opp under.

 

Demo

 

Kode

Klikk for å se/fjerne spoilerteksten nedenfor
function fillCategory(){ 
// this function is used to fill the category list on load
addOption(document.drop_list.Category, "Alfa Romeo", "Alfa Romeo", "");
addOption(document.drop_list.Category, "Audi", "Audi", "");
addOption(document.drop_list.Category, "BMW", "BMW", "");
addOption(document.drop_list.Category, "Chevrolet", "Chevrolet", "");
addOption(document.drop_list.Category, "Chrysler", "Chrysler", "");
addOption(document.drop_list.Category, "Citroen", "Citroen", "");
addOption(document.drop_list.Category, "Fiat", "Fiat", "");
addOption(document.drop_list.Category, "Ford", "Ford", "");
addOption(document.drop_list.Category, "Honda", "Honda", "");
addOption(document.drop_list.Category, "Hymer", "Hymer", "");
addOption(document.drop_list.Category, "Hyundai", "Hyundai", "");
addOption(document.drop_list.Category, "Iveco", "Iveco", "");
addOption(document.drop_list.Category, "Jaguar", "Jaguar", "");
addOption(document.drop_list.Category, "Jeep", "Jeep", "");
addOption(document.drop_list.Category, "Kia", "Kia", "");
addOption(document.drop_list.Category, "Lancia", "Lancia", "");
addOption(document.drop_list.Category, "Land Rover", "Land Rover", "");
addOption(document.drop_list.Category, "Mazda", "Mazda", "");
addOption(document.drop_list.Category, "Mercedes", "Mercedes", "");
addOption(document.drop_list.Category, "Mini", "Mini", "");
addOption(document.drop_list.Category, "Mitsubishi", "Mitsubishi", "");
addOption(document.drop_list.Category, "Nissan", "Nissan", "");
addOption(document.drop_list.Category, "Opel", "Opel", "");
addOption(document.drop_list.Category, "Peugeot", "Peugeot", "");
addOption(document.drop_list.Category, "Porsche", "Porsche", "");
addOption(document.drop_list.Category, "Renault", "Renault", "");
addOption(document.drop_list.Category, "Rover", "Rover", "");
addOption(document.drop_list.Category, "Saab", "Saab", "");
addOption(document.drop_list.Category, "Seat", "Seat", "");
addOption(document.drop_list.Category, "Skoda", "Skoda", "");
addOption(document.drop_list.Category, "Smart", "Smart", "");
addOption(document.drop_list.Category, "SsangYong", "SsangYong", "");
addOption(document.drop_list.Category, "Subaru", "Subaru", "");
addOption(document.drop_list.Category, "Suzuki", "Suzuki", "");
addOption(document.drop_list.Category, "Toyota", "Toyota", "");
addOption(document.drop_list.Category, "Volkswagen", "Volkswagen", "");
addOption(document.drop_list.Category, "Volvo", "Volvo", "");

}

function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
addOption(document.drop_list.SubCat, "", "Modell", "");


if(document.drop_list.Category.value == 'Alfa Romeo'){
addOption(document.drop_list.SubCat,"145", "145");
addOption(document.drop_list.SubCat,"146", "146");
addOption(document.drop_list.SubCat,"147", "147");
addOption(document.drop_list.SubCat,"155", "155");
addOption(document.drop_list.SubCat,"156", "156");
addOption(document.drop_list.SubCat,"156 Q4 Crosswagon", "156 Q4 Crosswagon");
addOption(document.drop_list.SubCat,"156 Sportwagon", "156 Sportwagon");
addOption(document.drop_list.SubCat,"159", "159");
addOption(document.drop_list.SubCat,"159 Sportwagon", "159 Sportwagon");
addOption(document.drop_list.SubCat,"164", "164");
addOption(document.drop_list.SubCat,"166", "166");
addOption(document.drop_list.SubCat,"Brera", "Brera");
addOption(document.drop_list.SubCat,"GT", "GT");
addOption(document.drop_list.SubCat,"Spider", "Spider");
}
if(document.drop_list.Category.value == 'Audi'){
addOption(document.drop_list.SubCat,"100", "100");
addOption(document.drop_list.SubCat,"80", "80");
addOption(document.drop_list.SubCat,"A2", "A2");
addOption(document.drop_list.SubCat,"A3", "A3");
addOption(document.drop_list.SubCat,"A4", "A4");
addOption(document.drop_list.SubCat,"A5", "A5");
addOption(document.drop_list.SubCat,"A6", "A6");
addOption(document.drop_list.SubCat,"A8", "A8");
addOption(document.drop_list.SubCat,"Allroad", "Allroad");
addOption(document.drop_list.SubCat,"Q5", "Q5");
addOption(document.drop_list.SubCat,"Q7", "Q7");
addOption(document.drop_list.SubCat,"TT", "TT");
}
if(document.drop_list.Category.value == 'BMW'){
addOption(document.drop_list.SubCat,"120d(E87)", "120d(E87)");
addOption(document.drop_list.SubCat,"318d(E90/E91/E92/E93)", "318d(E90/E91/E92/E93)");
addOption(document.drop_list.SubCat,"318d (E46)", "318d (E46)");
addOption(document.drop_list.SubCat,"318td (E46)", "318td (E46)");
addOption(document.drop_list.SubCat,"320d (E46)", "320d (E46)");
addOption(document.drop_list.SubCat,"320d(E90/E91/E92/E93)", "320d(E90/E91/E92/E93)");
addOption(document.drop_list.SubCat,"320td (E46)", "320td (E46)");
addOption(document.drop_list.SubCat,"325td (E36)", "325td (E36)");
addOption(document.drop_list.SubCat,"325tds (E36)", "325tds (E36)");
addOption(document.drop_list.SubCat,"330d (E46)", "330d (E46)");
addOption(document.drop_list.SubCat,"330d(E90/E91/E92/E93)", "330d(E90/E91/E92/E93)");
addOption(document.drop_list.SubCat,"335d(E90/E91/E92/E93)", "335d(E90/E91/E92/E93)");
addOption(document.drop_list.SubCat,"520d (E39)", "520d (E39)");
addOption(document.drop_list.SubCat,"520d (E60/E61)", "520d (E60/E61)");
addOption(document.drop_list.SubCat,"525d (E39)", "525d (E39)");
addOption(document.drop_list.SubCat,"525d (E60/E61)", "525d (E60/E61)");
addOption(document.drop_list.SubCat,"525td (E34)", "525td (E34)");
addOption(document.drop_list.SubCat,"525td (E39)", "525td (E39)");
addOption(document.drop_list.SubCat,"525tds (E34)", "525tds (E34)");
addOption(document.drop_list.SubCat,"525tds (E39)", "525tds (E39)");
addOption(document.drop_list.SubCat,"530d (E39)", "530d (E39)");
addOption(document.drop_list.SubCat,"530d (E60/61)", "530d (E60/61)");
addOption(document.drop_list.SubCat,"535d (E60/61)", "535d (E60/61)");
addOption(document.drop_list.SubCat,"730d (E38)", "730d (E38)");
addOption(document.drop_list.SubCat,"730d (E65/E66)", "730d (E65/E66)");
addOption(document.drop_list.SubCat,"740d (E38)", "740d (E38)");
addOption(document.drop_list.SubCat,"740d (E65/E66)", "740d (E65/E66)");
addOption(document.drop_list.SubCat,"745d (E65/E66)", "745d (E65/E66)");
addOption(document.drop_list.SubCat,"X3 (E83)", "X3 (E83)");
addOption(document.drop_list.SubCat,"X5 (E53)", "X5 (E53)");
}
if(document.drop_list.Category.value == 'Chevrolet'){
addOption(document.drop_list.SubCat,"Captiva", "Captiva");
addOption(document.drop_list.SubCat,"Epica", "Epica");
addOption(document.drop_list.SubCat,"Evanda", "Evanda");
}
if(document.drop_list.Category.value == 'Chrysler'){
addOption(document.drop_list.SubCat,"300C", "300C");
addOption(document.drop_list.SubCat,"Grand Voyager", "Grand Voyager");
addOption(document.drop_list.SubCat,"PT Cruiser", "PT Cruiser");
addOption(document.drop_list.SubCat,"Voyager", "Voyager");
}
if(document.drop_list.Category.value == 'Citroen'){
addOption(document.drop_list.SubCat,"Berlingo", "Berlingo");
addOption(document.drop_list.SubCat,"C-Crosser", "C-Crosser");
addOption(document.drop_list.SubCat,"C1", "C1");
addOption(document.drop_list.SubCat,"C2", "C2");
addOption(document.drop_list.SubCat,"C3", "C3");
addOption(document.drop_list.SubCat,"C4", "C4");
addOption(document.drop_list.SubCat,"C5", "C5");
addOption(document.drop_list.SubCat,"C8", "C8");
addOption(document.drop_list.SubCat,"Dispatch", "Dispatch");
addOption(document.drop_list.SubCat,"Evasion", "Evasion");
addOption(document.drop_list.SubCat,"Jumper", "Jumper");
addOption(document.drop_list.SubCat,"Jumpy", "Jumpy");
addOption(document.drop_list.SubCat,"Xantia", "Xantia");
addOption(document.drop_list.SubCat,"XM", "XM");
addOption(document.drop_list.SubCat,"Xsara", "Xsara");
}
if(document.drop_list.Category.value == 'Fiat'){
addOption(document.drop_list.SubCat,"Brava", "Brava");
addOption(document.drop_list.SubCat,"Bravo", "Bravo");
addOption(document.drop_list.SubCat,"Croma", "Croma");
addOption(document.drop_list.SubCat,"Doblo", "Doblo");
addOption(document.drop_list.SubCat,"Ducato", "Ducato");
addOption(document.drop_list.SubCat,"Gingo", "Gingo");
addOption(document.drop_list.SubCat,"Grande Punto", "Grande Punto");
addOption(document.drop_list.SubCat,"Idea", "Idea");
addOption(document.drop_list.SubCat,"Marea", "Marea");
addOption(document.drop_list.SubCat,"Multipia", "Multipia");
addOption(document.drop_list.SubCat,"Panda", "Panda");
addOption(document.drop_list.SubCat,"Punto", "Punto");
addOption(document.drop_list.SubCat,"Scudo", "Scudo");
addOption(document.drop_list.SubCat,"Sedici", "Sedici");
addOption(document.drop_list.SubCat,"Stilo", "Stilo");
addOption(document.drop_list.SubCat,"Trepiuno", "Trepiuno");
addOption(document.drop_list.SubCat,"Ulysse", "Ulysse");
}
if(document.drop_list.Category.value == 'Ford'){
addOption(document.drop_list.SubCat,"C-Max", "C-Max");
addOption(document.drop_list.SubCat,"Carving Titanium", "Carving Titanium");
addOption(document.drop_list.SubCat,"Euroline", "Euroline");
addOption(document.drop_list.SubCat,"Fiesta", "Fiesta");
addOption(document.drop_list.SubCat,"Focus", "Focus");
addOption(document.drop_list.SubCat,"Fusion", "Fusion");
addOption(document.drop_list.SubCat,"Galaxy", "Galaxy");
addOption(document.drop_list.SubCat,"Mondeo", "Mondeo");
addOption(document.drop_list.SubCat,"Nugget", "Nugget");
addOption(document.drop_list.SubCat,"S-Max", "S-Max");
addOption(document.drop_list.SubCat,"Tourneo Connect", "Tourneo Connect");
addOption(document.drop_list.SubCat,"Transit", "Transit");
}
if(document.drop_list.Category.value == 'Honda'){
addOption(document.drop_list.SubCat,"Accord", "Accord");
addOption(document.drop_list.SubCat,"Civic", "Civic");
addOption(document.drop_list.SubCat,"CR-V", "CR-V");
addOption(document.drop_list.SubCat,"FR-V", "FR-V");
addOption(document.drop_list.SubCat,"Jazz", "Jazz");
}
if(document.drop_list.Category.value == 'Hymer'){
addOption(document.drop_list.SubCat,"Exis Sport", "Exis Sport");
addOption(document.drop_list.SubCat,"Wohnmobil", "Wohnmobil");
}
if(document.drop_list.Category.value == 'Hyundai'){
addOption(document.drop_list.SubCat,"Accent", "Accent");
addOption(document.drop_list.SubCat,"Elantra", "Elantra");
addOption(document.drop_list.SubCat,"Exel", "Exel");
addOption(document.drop_list.SubCat,"Getz", "Getz");
addOption(document.drop_list.SubCat,"Matrix", "Matrix");
addOption(document.drop_list.SubCat,"Pony", "Pony");
addOption(document.drop_list.SubCat,"Santa Fe", "Santa Fe");
addOption(document.drop_list.SubCat,"Sonata V", "Sonata V");
addOption(document.drop_list.SubCat,"Trajet", "Trajet");
addOption(document.drop_list.SubCat,"Tucson", "Tucson");
addOption(document.drop_list.SubCat,"Verna", "Verna");
}
if(document.drop_list.Category.value == 'Iveco'){
addOption(document.drop_list.SubCat,"Daily", "Daily");
}
if(document.drop_list.Category.value == 'Jaguar'){
addOption(document.drop_list.SubCat,"S Type", "S Type");
addOption(document.drop_list.SubCat,"X Type", "X Type");
addOption(document.drop_list.SubCat,"XJ", "XJ");
addOption(document.drop_list.SubCat,"XK", "XK");
}
if(document.drop_list.Category.value == 'Jeep'){
addOption(document.drop_list.SubCat,"Cherokee", "Cherokee");
addOption(document.drop_list.SubCat,"Commander", "Commander");
addOption(document.drop_list.SubCat,"Compass", "Compass");
addOption(document.drop_list.SubCat,"Grand Cherokee", "Grand Cherokee");
addOption(document.drop_list.SubCat,"Patriot", "Patriot");
addOption(document.drop_list.SubCat,"Renegade", "Renegade");
addOption(document.drop_list.SubCat,"Wrangler", "Wrangler");
}
if(document.drop_list.Category.value == 'Kia'){
addOption(document.drop_list.SubCat,"Carens", "Carens");
addOption(document.drop_list.SubCat,"Carnival", "Carnival");
addOption(document.drop_list.SubCat,"Ceed", "Ceed");
addOption(document.drop_list.SubCat,"Cerato", "Cerato");
addOption(document.drop_list.SubCat,"Magentis", "Magentis");
addOption(document.drop_list.SubCat,"Retona", "Retona");
addOption(document.drop_list.SubCat,"Rio", "Rio");
addOption(document.drop_list.SubCat,"RS D4EA", "RS D4EA");
addOption(document.drop_list.SubCat,"Sorento", "Sorento");
addOption(document.drop_list.SubCat,"Sportage", "Sportage");
}
if(document.drop_list.Category.value == 'Lancia'){
addOption(document.drop_list.SubCat,"Kappa", "Kappa");
addOption(document.drop_list.SubCat,"Lybra", "Lybra");
addOption(document.drop_list.SubCat,"Musa", "Musa");
addOption(document.drop_list.SubCat,"Oro", "Oro");
addOption(document.drop_list.SubCat,"Phedra", "Phedra");
addOption(document.drop_list.SubCat,"Platino", "Platino");
addOption(document.drop_list.SubCat,"Thesis", "Thesis");
addOption(document.drop_list.SubCat,"Ypsilon", "Ypsilon");
addOption(document.drop_list.SubCat,"Zeta", "Zeta");
}
if(document.drop_list.Category.value == 'Land Rover'){
addOption(document.drop_list.SubCat,"Discovery3", "Discovery3");
addOption(document.drop_list.SubCat,"Freelander", "Freelander");
addOption(document.drop_list.SubCat,"Land Rover", "Land Rover");
addOption(document.drop_list.SubCat,"Range Rover", "Range Rover");
}
if(document.drop_list.Category.value == 'Mercedes'){
addOption(document.drop_list.SubCat,"A160 (W169)", "A160 (W169)");
addOption(document.drop_list.SubCat,"A170 (W168)", "A170 (W168)");
addOption(document.drop_list.SubCat,"A180 (W169)", "A180 (W169)");
addOption(document.drop_list.SubCat,"A200 (W169)", "A200 (W169)");
addOption(document.drop_list.SubCat,"B180 (W245)", "B180 (W245)");
addOption(document.drop_list.SubCat,"B200 (W245)", "B200 (W245)");
addOption(document.drop_list.SubCat,"C", "C");
addOption(document.drop_list.SubCat,"C220 (W203)", "C220 (W203)");
addOption(document.drop_list.SubCat,"C270 (W203)", "C270 (W203)");
addOption(document.drop_list.SubCat,"CL", "CL");
addOption(document.drop_list.SubCat,"CLK", "CLK");
addOption(document.drop_list.SubCat,"CLK220 (W209)", "CLK220 (W209)");
addOption(document.drop_list.SubCat,"CLK270 (W209)", "CLK270 (W209)");
addOption(document.drop_list.SubCat,"CLS", "CLS");
addOption(document.drop_list.SubCat,"E", "E");
addOption(document.drop_list.SubCat,"E200 (W211)", "E200 (W211)");
addOption(document.drop_list.SubCat,"E220 (W210)", "E220 (W210)");
addOption(document.drop_list.SubCat,"E220 (W211)", "E220 (W211)");
addOption(document.drop_list.SubCat,"E270 (W210)", "E270 (W210)");
addOption(document.drop_list.SubCat,"E280 (W211)", "E280 (W211)");
addOption(document.drop_list.SubCat,"G", "G");
addOption(document.drop_list.SubCat,"G400 (W463)", "G400 (W463)");
addOption(document.drop_list.SubCat,"GL420 (X164)", "GL420 (X164)");
addOption(document.drop_list.SubCat,"M", "M");
addOption(document.drop_list.SubCat,"ML280 (W164)", "ML280 (W164)");
addOption(document.drop_list.SubCat,"ML400 (W163)", "ML400 (W163)");
addOption(document.drop_list.SubCat,"ML420 (W164)", "ML420 (W164)");
addOption(document.drop_list.SubCat,"R", "R");
addOption(document.drop_list.SubCat,"S", "S");
addOption(document.drop_list.SubCat,"S400 (W220)", "S400 (W220)");
addOption(document.drop_list.SubCat,"SL", "SL");
addOption(document.drop_list.SubCat,"SLK", "SLK");
addOption(document.drop_list.SubCat,"Sprinter 215 (906)", "Sprinter 215 (906)");
addOption(document.drop_list.SubCat,"Sprinter 311 (901/2/3/4/5)", "Sprinter 311 (901/2/3/4/5)");
addOption(document.drop_list.SubCat,"Sprinter 315 (906)", "Sprinter 315 (906)");
addOption(document.drop_list.SubCat,"Sprinter 415 (906)", "Sprinter 415 (906)");
addOption(document.drop_list.SubCat,"Sprinter 515 (906)", "Sprinter 515 (906)");
addOption(document.drop_list.SubCat,"Vaneo 170 (W414)", "Vaneo 170 (W414)");
addOption(document.drop_list.SubCat,"Viano (693)", "Viano (693)");
addOption(document.drop_list.SubCat,"Vito 115 (639)", "Vito 115 (639)");
}
if(document.drop_list.Category.value == 'Mini'){
addOption(document.drop_list.SubCat,"Cooper", "Cooper");
addOption(document.drop_list.SubCat,"Cooper S", "Cooper S");
addOption(document.drop_list.SubCat,"One", "One");
addOption(document.drop_list.SubCat,"One D", "One D");
}
if(document.drop_list.Category.value == 'Mitsubishi'){
addOption(document.drop_list.SubCat,"Carisma", "Carisma");
addOption(document.drop_list.SubCat,"Colt", "Colt");
addOption(document.drop_list.SubCat,"Grandis", "Grandis");
addOption(document.drop_list.SubCat,"Outlander", "Outlander");
addOption(document.drop_list.SubCat,"Space Star", "Space Star");
}
if(document.drop_list.Category.value == 'Nissan'){
addOption(document.drop_list.SubCat,"Almera", "Almera");
addOption(document.drop_list.SubCat,"Kubistar", "Kubistar");
addOption(document.drop_list.SubCat,"Micra", "Micra");
addOption(document.drop_list.SubCat,"Note", "Note");
addOption(document.drop_list.SubCat,"Primera", "Primera");
addOption(document.drop_list.SubCat,"Qashqai", "Qashqai");
addOption(document.drop_list.SubCat,"Sentra", "Sentra");
addOption(document.drop_list.SubCat,"Terrano 2", "Terrano 2");
addOption(document.drop_list.SubCat,"Tidda", "Tidda");
addOption(document.drop_list.SubCat,"Versa", "Versa");
}
if(document.drop_list.Category.value == 'Opel'){
addOption(document.drop_list.SubCat,"Astra", "Astra");
addOption(document.drop_list.SubCat,"Combo", "Combo");
addOption(document.drop_list.SubCat,"Corsa", "Corsa");
addOption(document.drop_list.SubCat,"Frontera", "Frontera");
addOption(document.drop_list.SubCat,"Meriva", "Meriva");
addOption(document.drop_list.SubCat,"Signum", "Signum");
addOption(document.drop_list.SubCat,"Sintra", "Sintra");
addOption(document.drop_list.SubCat,"Speedster", "Speedster");
addOption(document.drop_list.SubCat,"Vectra", "Vectra");
addOption(document.drop_list.SubCat,"Vivaro", "Vivaro");
addOption(document.drop_list.SubCat,"Zafira", "Zafira");
}
if(document.drop_list.Category.value == 'Peugeot'){
addOption(document.drop_list.SubCat,"1007", "1007");
addOption(document.drop_list.SubCat,"107", "107");
addOption(document.drop_list.SubCat,"206", "206");
addOption(document.drop_list.SubCat,"207", "207");
addOption(document.drop_list.SubCat,"306", "306");
addOption(document.drop_list.SubCat,"4007", "4007");
addOption(document.drop_list.SubCat,"406", "406");
addOption(document.drop_list.SubCat,"407", "407");
addOption(document.drop_list.SubCat,"607", "607");
addOption(document.drop_list.SubCat,"806", "806");
addOption(document.drop_list.SubCat,"807", "807");
addOption(document.drop_list.SubCat,"Boxer", "Boxer");
addOption(document.drop_list.SubCat,"Expert", "Expert");
addOption(document.drop_list.SubCat,"Partner", "Partner");
addOption(document.drop_list.SubCat,"Ranch", "Ranch");
}
if(document.drop_list.Category.value == 'Porsche'){
addOption(document.drop_list.SubCat,"Cayenne", "Cayenne");
}
if(document.drop_list.Category.value == 'Renault'){
addOption(document.drop_list.SubCat,"Avantime", "Avantime");
addOption(document.drop_list.SubCat,"Clio", "Clio");
addOption(document.drop_list.SubCat,"Espace", "Espace");
addOption(document.drop_list.SubCat,"Kangoo", "Kangoo");
addOption(document.drop_list.SubCat,"Laguna", "Laguna");
addOption(document.drop_list.SubCat,"Master", "Master");
addOption(document.drop_list.SubCat,"Megane", "Megane");
addOption(document.drop_list.SubCat,"Modus", "Modus");
addOption(document.drop_list.SubCat,"Pampa", "Pampa");
addOption(document.drop_list.SubCat,"Scenic", "Scenic");
addOption(document.drop_list.SubCat,"Trafic", "Trafic");
addOption(document.drop_list.SubCat,"Twingo", "Twingo");
addOption(document.drop_list.SubCat,"Vel Satis", "Vel Satis");
}
if(document.drop_list.Category.value == 'Rover'){
addOption(document.drop_list.SubCat,"220", "220");
addOption(document.drop_list.SubCat,"25", "25");
addOption(document.drop_list.SubCat,"45", "45");
addOption(document.drop_list.SubCat,"75", "75");
}
if(document.drop_list.Category.value == 'Saab'){
addOption(document.drop_list.SubCat,"9-3", "9-3");
addOption(document.drop_list.SubCat,"9-5", "9-5");
}
if(document.drop_list.Category.value == 'Seat'){
addOption(document.drop_list.SubCat,"Alhambra", "Alhambra");
addOption(document.drop_list.SubCat,"Altea", "Altea");
addOption(document.drop_list.SubCat,"Arosa", "Arosa");
addOption(document.drop_list.SubCat,"Cordoba", "Cordoba");
addOption(document.drop_list.SubCat,"Ibiza", "Ibiza");
addOption(document.drop_list.SubCat,"Inca", "Inca");
addOption(document.drop_list.SubCat,"Leon", "Leon");
addOption(document.drop_list.SubCat,"Toledo", "Toledo");
}
if(document.drop_list.Category.value == 'Skoda'){
addOption(document.drop_list.SubCat,"Fabia", "Fabia");
addOption(document.drop_list.SubCat,"Octavia", "Octavia");
addOption(document.drop_list.SubCat,"Roomster", "Roomster");
addOption(document.drop_list.SubCat,"Superb", "Superb");
}
if(document.drop_list.Category.value == 'Smart'){
addOption(document.drop_list.SubCat,"ForFour", "ForFour");
}
if(document.drop_list.Category.value == 'SsangYong'){
addOption(document.drop_list.SubCat,"Actyon", "Actyon");
addOption(document.drop_list.SubCat,"Kyron", "Kyron");
addOption(document.drop_list.SubCat,"Rexton", "Rexton");
addOption(document.drop_list.SubCat,"Rodius", "Rodius");
addOption(document.drop_list.SubCat,"Stavic", "Stavic");
}
if(document.drop_list.Category.value == 'Subaru'){
addOption(document.drop_list.SubCat,"Legacy", "Legacy");
addOption(document.drop_list.SubCat,"Outback", "Outback");
}
if(document.drop_list.Category.value == 'Suzuki'){
addOption(document.drop_list.SubCat,"Escudo", "Escudo");
addOption(document.drop_list.SubCat,"Grand Vitara", "Grand Vitara");
addOption(document.drop_list.SubCat,"Ignis", "Ignis");
addOption(document.drop_list.SubCat,"Swift", "Swift");
addOption(document.drop_list.SubCat,"SX-4", "SX-4");
addOption(document.drop_list.SubCat,"Vitara", "Vitara");
addOption(document.drop_list.SubCat,"WagonR", "WagonR");
}
if(document.drop_list.Category.value == 'Toyota'){
addOption(document.drop_list.SubCat,"Auris", "Auris");
addOption(document.drop_list.SubCat,"Corolla", "Corolla");
addOption(document.drop_list.SubCat,"Yaris", "Yaris");
}
if(document.drop_list.Category.value == 'Volkswagen'){
addOption(document.drop_list.SubCat,"Beetle", "Beetle");
addOption(document.drop_list.SubCat,"Bora", "Bora");
addOption(document.drop_list.SubCat,"Caddy", "Caddy");
addOption(document.drop_list.SubCat,"Caravelle", "Caravelle");
addOption(document.drop_list.SubCat,"Eos", "Eos");
addOption(document.drop_list.SubCat,"Golf", "Golf");
addOption(document.drop_list.SubCat,"Jetta", "Jetta");
addOption(document.drop_list.SubCat,"LT", "LT");
addOption(document.drop_list.SubCat,"Lupo", "Lupo");
addOption(document.drop_list.SubCat,"Multivan", "Multivan");
addOption(document.drop_list.SubCat,"Passat", "Passat");
addOption(document.drop_list.SubCat,"Phaeton", "Phaeton");
addOption(document.drop_list.SubCat,"Polo", "Polo");
addOption(document.drop_list.SubCat,"Sharan", "Sharan");
addOption(document.drop_list.SubCat,"T4", "T4");
addOption(document.drop_list.SubCat,"T5", "T5");
addOption(document.drop_list.SubCat,"Toureg", "Toureg");
addOption(document.drop_list.SubCat,"Touran", "Touran");
addOption(document.drop_list.SubCat,"Vento", "Vento");
}
if(document.drop_list.Category.value == 'Volvo'){
addOption(document.drop_list.SubCat,"850", "850");
addOption(document.drop_list.SubCat,"C30", "C30");
addOption(document.drop_list.SubCat,"C70", "C70");
addOption(document.drop_list.SubCat,"S40", "S40");
addOption(document.drop_list.SubCat,"S60", "S60");
addOption(document.drop_list.SubCat,"S80", "S80");
addOption(document.drop_list.SubCat,"V40", "V40");
addOption(document.drop_list.SubCat,"V50", "V50");
addOption(document.drop_list.SubCat,"V70", "V70");
addOption(document.drop_list.SubCat,"XC 50", "XC 50");
addOption(document.drop_list.SubCat,"XC 60", "XC 60");
addOption(document.drop_list.SubCat,"XC 70", "XC 70");
addOption(document.drop_list.SubCat,"XC 90", "XC 90");
}


}
////////////////// 

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
	//selectbox.options.remove(i);
	selectbox.remove(i);
}
}


function addOption(selectbox, value, text )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;

selectbox.options.add(optn);
}

[/spolier]

Endret av Brød
Lenke til kommentar

Du kan legge det i en tabell.

Der har du felt for merke, modell, årsmodell,orginaleffek, effektøkning, graf og pris.

 

Så kan du ved hjelp av AJAX lage dropdown menyene.

Har et eksempel på jobb pc. Men det var noe jeg fant når jeg googlet (ajax dropdown mysql)

 

Det går ut på at når du velger merke, så spør den i DB etter aller rader som har dette merket og returnerer modell feltet., Når bruker har valgt modell, spør den igjen i DB etter alle rader som har denne modellen, og returnerer mulig motor alternativ. Når bruker har valgt motor så spørres det ¨på nytt i basen etter alle rader med denne motor (og merke hvis samma motor finnes i flere merker) og returnerer mulige effektøkninger.

 

Slik fortsetter du til alle felter er valgt.

Lenke til kommentar
Ja skjønner poenget, trenger bare den lille rettledningen. Har skjønt at jeg bør se på mysql_query i manualen? Kan jeg bruke Javascript dropdown-koden jeg har lagd videre?

 

 

Tja du kan jo bruke koden, men jeg ville bygd det opp i en database. Så lager den dropdown menyene dynamisk. Vil bli en penere kode.

 

Mysql_query er en av kommandoene du bruker opp mot en mysql database ja.

Lenke til kommentar

Dersom jeg skulle ha gjort noe som dette, hadde jeg nok brukt AJAX som nevnt tidligere her. Du bruker et server-side-språk til å kommunisere med databasen, og hente informasjon om bilene du vil vise informasjon om. Så kan du representere den informasjonen som f.eks. xml, og sende den videre til nettleseren som kan vise den frem nedenfor dropdownmenyene dine.

 

Om du ikke har noe peiling på AJAX, kan du f.eks. se på w3schools sine sider, der tror jeg det skal være ganske greit forklart.

http://www.w3schools.com/ajax/

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...