Jump to content

Jquery Not Working $("#model2 option[value='Punto Evo']").attr('selected',


Recommended Posts

I have a list of car makes and models when you select a car the model dropbox is populated with the diffrent types of models relevant to that make you have chosen.

 

Thing is i need to submint values like manufacturer=Alfa+Romeo&Model=Alfa+155 to this form where it auto pre seletes what you have seleted on the home page (form)

 

it works for the manufacturer (pre selects it) however it does not work for model is this because the dropdown is generated on the fly do i need to access it a diffrent way? heres the code

 

 
var model = ['','Abarth','Acura','Alfa Romeo','Alpina','Artega','Asia Motors','Aston Martin','Audi','Austin','Austin Healey','Bentley','BMW','Borgward','Brilliance','Bugatti','Buick','Cadillac','Casalini','Caterham','Chevrolet','Chrysler','Citroën','Cobra','Corvette','Dacia','Daewoo','Daihatsu','DeTomaso','Dodge','Ferrari','Fiat','Ford','GMC','Grecav','Holden','Honda','Hummer','Hyundai','Isuzu','Iveco','Jaguar','Jeep','Kia','Königsegg','KTM','Lada','Lamborghini','Lancia','Land Rover','Landwind','Lexus','Ligier','Lincoln','Lotus','Mahindra','Maserati','Maybach','Mazda','McLaren','Mercedes-Benz','MG','MINI','Mitsubishi','Morgan','Nissan','NSU','Oldsmobile','Opel','Pagani','Peugeot','Piaggio','Plymouth','Pontiac','Porsche','Proton','Renault','Rolls Royce','Rover','Ruf','Saab','Santana','Seat','Škoda','Smart','Spyker','Ssangyong','Subaru','Suzuki','Talbot','Tata','Tesla','Toyota','Trabant','Triumph','TVR','Volkswagen','Volvo','Wartburg','Westfield','Wiesmann']; //Set makes

    model[1] = ['500', '500C', 'Grande Punto', 'Punto Evo', 'Other']; // Set Abarth models
    model[2] = ['NSX', 'RL', 'RSX', 'TL', 'TSX', 'Other']; // Set Acura models
    model[3] = ['8C', 'Alfa 145', 'Alfa 146', 'Alfa 147', 'Alfa 149', 'Alfa 155', 'Alfa 156', 'Alfa 159', 'Alfa 164', 'Alfa 166', 'Alfa 33', 'Alfa 75', 'Alfa 90', 'Alfasud', 'Alfetta', 'Brera', 'Crosswagon', 'Giulia', 'Giulietta', 'GT', 'GTV', 'Junior', 'MiTo', 'Spider', 'Sprint', 'Other'];     // Alfa Romeo models
 model[4] = ['B10', 'B12', 'B3', 'B5', 'B6', 'B7', 'B8', 'D 10', 'D3', 'Roadster S', 'Other']; // Set Alpina models
 model[5] = ['GT', 'Other']; // Set Artega models
 model[6] = ['Rocsta', 'Other']; // Set Asia Motors models
 model[7] = ['AR1', 'Cygnet', 'DB', 'DB7', 'DB9', 'DBS', 'Lagonda', 'Rapide', 'V12 Vantage', 'V8', 'V8 Vantage', 'Vanquish', 'Vantage', 'Virage', 'Volante', 'Other']; // Set Aston Martin models
 model[8] = ['100',' 200',' 80',' 90',' A1',' A2',' A3',' A4',' A4 Allroad',' A5',' A6',' A6 Allroad',' A7',' A8',' Cabriolet',' Coupé',' Q3',' Q5',' Q7',' QUATTRO',' R8',' RS2',' RS3',' RS4',' RS5',' RS6',' S2',' S3',' S4',' S5',' S6',' S8',' TT (All)',' TT',' TT RS',' TTS',' V8',' Other']; // Set Audi models
 model[9] = ['Other']; // Set Austin models
 model[10] = ['Other']; // Set Austin Healey models
 model[11] = ['Arnage',' Azure',' Brooklands',' Continental',' Continental Flying Spur',' Continental GT>',' Continental GTC',' Continental Supersports',' Eight',' Mulsanne',' Turbo R',' Turbo RT',' Turbo S',' Other']; // Set Bentley models
 model[12] = ['Series 1 (All)','     116','     118','     120','     123','     125','     130','     135',' 2002',' Series 3 (All)','     315','     316','     318','     320','     323','     324','     325','     328','     330','     335',' Series 5 (All)','     518','     520','     523','     524','     525','     528','     530','     530 Gran Turismo','     535','     535 Gran Turismo','     540','     545','     550','     550 Gran Turismo','     ActiveHybrid 5',' Series 6 (All)','     628','     630','     633','     635','     640','     645','     650',' Series 7 (All)','     725','     728','     730','     732','     735','     740','     745','     750','     760','     ActiveHybrid 7',' M Models (All)','     1er M','     M3','     M5','     M6','     X5 M','     X6 M','     Z3 M','     Z4 M',' Series X (All)','     ActiveHybrid X6','     X1','     X3','     X5','     X5 M','     X6','     X6 M',' Series Z (All)','     Z1','     Z3','     Z3 M','     Z4','     Z4 M','     Z8',' Other']; // Set BMW models
 model[13] = ['Other']; // Set Borgward models
 model[14] = ['BC3',' BS2',' BS4',' BS6',' Other']; // Set Brilliance models
 model[15] = ['EB 110 Veyron Other']; // Set Bugatti models
 model[16] = ['Century',' Electra',' Enclave',' La Crosse',' Le Sabre',' Park Avenue',' Regal',' Riviera',' Roadmaster',' Skylark',' Other']; // Set Buick models
 model[17] = ['Allante',' BLS',' CTS',' Deville',' Eldorado',' Escalade',' Fleetwood',' Seville',' SRX',' STS',' XLR',' Other']; // Set Cadillac models
 model[18] = ['Other']; // Set Casalini models
 model[19] = ['Other']; // Set Caterham models
 model[20] = ['2500',' Alero',' Astro',' Avalanche',' Aveo',' Beretta',' Blazer',' C1500',' Camaro',' Caprice',' Captiva',' Cavalier',' Chevelle',' Chevy Van',' Citation',' Colorado',' Corsica',' Cruze',' El Camino',' Epica',' Evanda',' Express',' G',' HHR',' Impala',' K1500',' K30',' Kalos',' Lacetti',' Lumina',' Malibu',' Matiz',' Nubira',' Orlando',' Rezzo',' S-10',' Silverado',' Spark',' SSR',' Suburban',' Tahoe',' Trailblazer',' Trans Sport',' Venture',' Volt']; // Set Chevrolet models
 model[21] = ['300 M',' 300C',' Aspen',' Crossfire',' Daytona',' ES',' Grand Voyager',' GS',' GTS',' Imperial',' Le Baron',' Neon',' New Yorker',' Pacifica',' PT Cruiser',' Saratoga',' Sebring',' Stratus',' Valiant',' Viper',' Vision',' Voyager',' Other']; // Set Chrysler models 
  model[22] = ['2 CV',' AX',' Berlingo',' BX',' C-Crosser',' C-Zero',' C1',' C2',' C3',' C3 Picasso',' C4',' C4 Picasso',' C5',' C6',' C8',' CX',' DS',' DS3',' DS4',' Evasion',' Grand C4 Picasso',' GSA',' Jumper',' Jumpy',' Nemo',' SAXO',' SM',' Visa',' Xantia',' XM',' Xsara',' Xsara Picasso',' ZX',' Other']; // Set Citroën models
  model[23] = ['Other']; // Set Cobra models
  model[24] = ['C3', 'C4', 'C5', 'C6', 'ZR 1', 'Other']; // Set Corvette models
  model[25] = ['Duster',' Logan',' Pick Up',' Sandero',' Other']; // Set Dacia models
  model[26] = ['Espero',' Evanda',' Kalos',' Korando',' Lacetti',' Lanos',' Leganza',' Matiz',' Musso',' Nexia',' Nubira',' Rezzo',' Tacuma',' Other',]; // Set Daewoo models
  model[27] = ['Applause',' Charade',' Charmant',' Copen',' Cuore',' Feroza/Sportrak',' Freeclimber',' Gran Move',' Hijet',' MATERIA',' Move',' Rocky/Fourtrak',' Sirion',' Terios',' TREVIS',' YRV',' Other']; // Set Daihatsu models
  model[28] = ['Guarà',' Pantera',' Other']; // Set DeTomaso models
  model[29] = ['Avenger',' Caliber',' Challenger',' Charger',' Dakota',' Demon',' Durango',' Grand Caravan',' Hornet',' Journey',' Magnum',' Neon',' Nitro',' RAM',' Stealth',' Viper',' Other']; // Set Dodge models
  model[30] = ['208',' 246',' 250',' 275',' 288',' 308',' 328',' 330',' 348',' 360',' 365',' 400',' 412',' 456',' 458',' 512',' 550',' 575',' 599 GTB',' 612',' 750',' California',' Daytona',' Dino GT4',' Enzo Ferrari',' F355',' F40',' F430',' F50',' FF',' Mondial',' Superamerica',' Testarossa',' Other']; // Set Ferrari models
  model[31] = ['124',' 126',' 127',' 130',' 131',' 500',' Barchetta',' Brava',' Bravo',' Cinquecento',' Coupe',' Croma',' Dino',' Doblo',' Ducato',' Fiorino',' Freemont',' Grande Punto',' Idea',' Linea',' Marea',' Marengo',' Multipla',' Palio',' Panda',' Punto',' Punto Evo',' Qubo',' Regata',' Ritmo',' Scudo',' Sedici',' Seicento',' Spider Europa',' Stilo',' Strada',' Tempra',' Tipo',' Ulysse',' Uno',' FIAT:X_1_9',' Other']; // Set Fiat models
  model[32] = ['Aerostar',' Bronco',' C-Max',' Capri',' Cougar',' Courier',' Crown',' Econoline',' Econovan',' Edge',' Escape',' Escort',' Excursion',' Expedition',' Explorer',' Express',' F 150',' F 250',' F 350',' Fairlane',' Falcon',' Fiesta',' Flex',' Focus',' Focus C-Max',' Fusion',' Galaxy',' Granada',' Grand C-Max',' GT',' Ka',' Kuga',' Maverick',' Mercury',' Mondeo',' Mustang',' Orion',' Probe',' Puma',' Ranger',' S-Max',' Scorpio',' Sierra',' Sportka',' Streetka',' Taunus',' Taurus',' Thunderbird',' Tourneo',' Transit (All)',' Transit',' Transit Connect',' Windstar',' Other']; // Set Ford models
  model[33] = ['Envoy',' Safari',' Savana',' Sierra',' Sonoma',' Syclone',' Typhoon',' Vandura',' Yukon',' Other']; // Set GMC models
  model[34] = ['Sonique',' Other']; // Set Grecav models
  model[35] = ['Other']; // Set Holden models
  model[36] = ['Accord',' Aerodeck',' Civic',' Concerto',' CR-V',' CR-Z',' CRX',' Element',' FR-V',' HR-V',' Insight',' Integra',' Jazz',' Legend',' Logo',' NSX',' Odyssey',' Prelude',' S2000',' Shuttle',' Stream',' Other']; // Set Honda models
  model[37] = ['H1',' H2',' H3',' Other']; // Set Hummer models
  model[38] = ['Accent',' Atos',' Azera',' Coupe',' Elantra',' Excel',' Galloper',' Genesis',' Getz',' Grandeur',' H 100',' H 200',' H-1',' H-1 Starex',' i10',' i20',' i30',' i40',' i50',' ix20',' ix35',' ix55',' Lantra',' Matrix',' Pony',' S-Coupe',' Santa Fe',' Santamo',' Sonata',' Terracan',' Trajet',' Tucson',' Veloster',' Veracruz',' XG 30',' XG 350',' Other']; // Set Hyundai models
  model[39] = ['Campo',' D-Max',' Gemini',' Midi',' PICK UP',' Trooper',' Other']; // Set Isuzu models 
  model[40] = ['Massif',' Other']; // Set Iveco models 
  model[41] = ['Daimler',' E-Type',' MK II',' S-Type',' X-Type',' XF',' XJ',' XJ12',' XJ40',' XJ6',' XJ8',' XJR',' XJS',' XJSC',' XK',' XKR',' Other']; // Set Jaguar models 
  model[42] = ['Cherokee',' CJ',' Comanche',' Commander',' Compass',' Grand Cherokee',' Patriot',' Renegade',' Wagoneer',' Willys',' Wrangler',' Other']; // Set Jeep models 
  model[43] = ['Besta',' Borrego',' Carens',' Carnival',' ceed',' cee d_sw',' Cerato',' Clarus',' Elan',' Joice',' K2500',' K2700',' Leo',' Magentis',' Mentor',' Mini',' Opirus',' Picanto',' Pregio',' Pride',' pro_ceed',' Retona',' Rio',' Roadster',' Rocsta',' Sephia',' Shuma',' Sorento',' Soul',' Sportage',' Venga',' Other']; // Set Kia models 
  model[44] = ['CCR',' Other']; // Set Königsegg models 
  model[45] = ['X-BOW',' Other']; // Set KTM models 
  model[46] = ['110',' 111',' 112',' 1200',' 2107',' 2110',' 2111',' 2112',' Aleko',' Forma',' Kalina',' Niva',' Nova',' Priora',' Samara',' Other']; // Set Lada models 
  model[47] = ['Aventador',' Countach',' Diablo',' Espada',' Gallardo',' Jalpa',' LM',' Miura',' Murciélago',' Urraco',' Other']; // Set Lamborghini models 
  model[48] = ['Beta',' Dedra',' Delta',' Flaminia',' Fulvia',' Gamma',' Kappa',' Lybra',' MUSA',' Phedra',' Prisma',' Stratos',' Thema',' Thesis',' Voyager',' Ypsilon',' Zeta',' Other']; // Set Lancia models 
  model[49] = ['Defender',' Discovery',' Freelander',' Range Rover',' Range Rover Evoque',' Range Rover Sport',' Serie I',' Serie II',' Serie III',' Other']; // Set Land Rover models 
  model[50] = ['S',' SC2',' SC4',' Other']; // Set Landwind models 
  model[51] = ['CT 200h',' ES Series (All)',' ES 300',' ES 330',' ES 350',' GS Series (All)',' GS 300',' GS 350',' GS 430',' GS 450',' GS 460',' GX 470',' IS Series (All)',' IS 200',' IS 220',' IS 250',' IS 300',' IS 350',' IS-F',' LS Series (All)',' LS 400',' LS 430',' LS 460',' LS 600',' LX Series (All)',' LX 470',' LX 570',' RX Series (All)',' RX 300',' RX 330',' RX 350',' RX 400',' RX 450',' SC 400',' SC 430',' Other']; // Set Lexus models 
  model[52] = ['Ambra',' Nova',' Optima',' X - Too',' Other']; // Set Ligier models
  model[53] = ['Aviator',' Continental',' LS',' Mark',' Navigator',' Town Car',' Other']; // Set Lincoln models
  model[54] = ['340 R',' Cortina',' Elan',' Elise',' Elite',' Esprit',' Europa',' Evora',' Excel',' Exige',' Super Seven',' V8',' Other']; // Set Lotus models
  model[55] = ['Other']; // Set Mahindra models
  model[56] = ['222',' 224',' 228',' 3200',' 418',' 420',' 4200',' 422',' 424',' 430',' Biturbo',' Ghibli',' GranCabrio',' Gransport',' Granturismo',' Indy',' Karif',' MC12',' Merak',' Quattroporte',' Shamal',' Spyder',' Other']; // Set Maserati models
  model[57] = ['57',' 62',' Other']; // Set Maybach models
  model[58] = ['121',' 2',' 3',' 323',' 5',' 6',' 626',' 929',' B series',' Bongo',' BT-50',' CX-7',' CX-9',' Demio',' E series',' Mazda2',' Mazda3',' Mazda5',' Mazda6',' Millenia',' MPV',' MX-3',' MX-5',' MX-6',' Premacy',' Protege RX-6',' RX-7',' RX-8',' Tribute',' Xedos',' Other']; // Set Mazda models
  model[59] = ['MP4-12C',' Other']; // Set McLaren models
  model[60] = ['190',' 200',' 220',' 230',' 240',' 250',' 260',' 270',' 280',' 290',' 300',' 320',' 350',' 380',' 400',' 416',' 420',' 450',' 500',' 560',' 600',' A-Klasse (All)',' A 140',' A 150',' A 160',' A 170',' A 180',' A 190',' A 200',' A 210',' B-Klasse (All)',' B 150',' B 160',' B 170',' B 180',' B 200',' C-Klasse (All)',' C 160',' C 180',' C 200',' C 220',' C 230',' C 240',' C 250',' C 270',' C 280',' C 30 AMG',' C 300',' C 32 AMG',' C 320',' C 350',' C 36 AMG',' C 43 AMG',' C 55 AMG',' C 63 AMG',' CE-Klasse (All)',' CE 200',' CE 220',' CE 300',' CL-Klasse (All)',' CL 160',' CL 180',' CL 200',' CL 220',' CL 230',' CL 320',' CL 420',' CL 500',' CL 55 AMG',' CL 600',' CL 63 AMG',' CL 65 AMG',' CLC-Klasse (All)',' CLC 160',' CLC 180',' CLC 200',' CLC 220',' CLC 230',' CLC 250',' CLC 350',' CLK-Klasse (All)',' CLK 200',' CLK 220',' CLK 230',' CLK 240',' CLK 270',' CLK 280',' CLK 320',' CLK 350',' CLK 430',' CLK 500',' CLK 55 AMG',' CLK 63 AMG',' CLS-Klasse (All)',' CLS 250',' CLS 280',' CLS 300',' CLS 320',' CLS 350',' CLS 500',' CLS 55 AMG',' CLS 63 AMG',' E-Klasse (All)',' E 200',' E 220',' E 230',' E 240',' E 250',' E 260',' E 270',' E 280',' E 290',' E 300',' E 320',' E 350',' E 36 AMG',' E 400',' E 420',' E 430',' E 50',' E 500',' E 55 AMG',' E 60 AMG',' E 63 AMG',' G-Klasse (All)',' G 230',' G 240',' G 250',' G 270',' G 280',' G 290',' G 300',' G 320',' G 350',' G 400',' G 500',' G 55 AMG',' GL-Klasse (All)',' GL 320',' GL 350',' GL 420',' GL 450',' GL 500',' GL 55 AMG',' GL 63 AMG',' GLK-Klasse (All)',' GLK 200',' GLK 220',' GLK 250',' GLK 280',' GLK 300',' GLK 320',' GLK 350',' MB 100',' ML-Klasse (All)',' ML 230',' ML 250',' ML 270',' ML 280',' ML 300',' ML 320',' ML 350',' ML 400',' ML 420',' ML 430',' ML 450',' ML 500',' ML 55 AMG',' ML 63 AMG',' R-Klasse (All)',' R 280',' R 300',' R 320',' R 350',' R 500',' R 63 AMG',' S-Klasse (All)',' S 250',' S 260',' S 280',' S 300',' S 320',' S 350',' S 400',' S 420',' S 430',' S 450',' S 500',' S 55',' S 550',' S 600',' S 63 AMG',' S 65 AMG',' SL-Klasse (All)',' SL 280',' SL 300',' SL 320',' SL 350',' SL 380',' SL 420',' SL 450',' SL 500',' SL 55 AMG',' SL 560',' SL 60 AMG',' SL 600',' SL 63 AMG',' SL 65 AMG',' SL 70 AMG',' SL 73 AMG',' SLK-Klasse (All)',' SLK 200',' SLK 230',' SLK 250',' SLK 280',' SLK 300',' SLK 32 AMG',' SLK 320',' SLK 350',' SLK 55 AMG',' SLR',' SLS AMG',' Sprinter',' V-Klasse (All)',' V 200',' V 220',' V 230',' V 280',' Vaneo',' Vario',' Viano',' Vito',' Other']; // Set Mercedes-Benz models
  model[61] = ['MGA',' MGB',' MGF',' Midget',' Montego',' TD',' TF',' ZR',' ZS',' ZT',' Other']; // Set MG models
  model[62] = ['1000',' 1300',' Clubman',' Cooper',' Cooper S',' Cooper SD',' Countryman',' John Cooper Works',' ONE',' Other']; // Set Mini models
  model[63] = ['3000 GT',' ASX',' Canter',' Carisma',' Colt',' Cordia',' Cosmos',' Diamante',' Eclipse',' Galant',' Galloper',' Grandis',' i-MiEV',' L200',' L300',' L400',' Lancer',' Montero',' Outlander',' Pajero',' Pajero Pinin',' Pick-up',' Santamo',' Sapporo',' Sigma',' Space Gear',' Space Runner',' Space Star',' Space Wagon',' Starion',' Tredia',' Other']; // Set Mitsubishi models
  model[64] = ['4/4',' Aero 8',' Plus 4',' Plus 8',' Roadster',' Other']; // Set Morgan models
  model[65] = ['100 NX',' 200 SX',' 240 SX',' 280 ZX',' 300 ZX',' 350Z',' 370Z',' Almera',' Almera Tino',' Altima',' Armada',' Bluebird',' Cabstar',' Cargo',' Cherry',' Cube',' Frontier',' GT-R',' Interstar',' Juke',' King Cab',' Kubistar',' Laurel',' Leaf',' Maxima',' Micra',' Murano',' Navara',' Note',' NP 300',' NV200',' Pathfinder',' Patrol',' Pixo',' Prairie',' Primastar',' Primera',' Qashqai',' Qashqai+2',' Quest',' Sentra',' Serena',' Silvia',' Skyline',' Sunny',' Terrano',' Tiida',' Titan',' Trade',' Urvan',' Vanette',' X-Trail']; // Set Nissan models
  model[66] = ['Other']; // Set NSU models
  model[67] = ['Bravada',' Custom Cruiser',' Cutlass',' Delta 88',' Silhouette',' Supreme',' Toronado',' Other']; // Set Oldsmobile models
  model[68] = ['Agila',' Ampera',' Antara',' Arena',' Ascona',' Astra',' Calibra',' Campo',' Cavalier',' Combo',' Commodore',' Corsa',' Diplomat',' Frontera',' GT',' Insignia',' Kadett',' Manta',' Meriva',' Monterey',' Monza',' Movano',' Nova',' Omega',' Pick Up Sportscap',' Rekord',' Senator',' Signum',' Sintra',' Speedster',' Tigra',' Vectra',' Vivaro',' Zafira',' Zafira Tourer',' Other']; // Set Opel models
  model[69] = ['Other']; // Set Pagani models
  model[70] = ['1007',' 104',' 106',' 107',' 204',' 205',' 206',' 207',' 3008',' 304',' 305',' 306',' 307',' 308',' 309',' 4007',' 404',' 405',' 406',' 407',' 5008',' 504',' 505',' 508',' 604',' 605',' 607',' 806',' 807',' Bipper',' Bipper Tepee',' Boxer',' Expert',' Expert Tepee',' iOn',' J5',' Partner',' Partner Tepee',' RCZ',' TePee',' Other']; // Set Peugeot models
  model[71] = ['APE',' APE TM',' Porter',' Other']; // Set Piaggio models
  model[72] = ['Prowler',' Other']; // Set Plymouth models
  model[73] = ['6000',' Bonneville',' Fiero',' Firebird',' G6',' Grand-Am',' Grand-Prix',' GTO',' Montana',' Solstice',' Sunbird',' Sunfire',' Targa',' Trans Am',' Trans Sport',' Vibe',' Other']; // Set Pontiac models
  model[74] = ['356',' 911 (All)',' 911',' 964',' 993',' 996',' 997',' 912',' 914',' 924',' 928',' 944',' 959',' 962',' 968',' Boxster',' Carrera GT',' Cayenne',' Cayman',' Panamera',' Other']; // Set Porsche models
  model[75] = ['300 Serie',' 400 Serie',' Other']; // Set Proton models
  model[76] = ['Alpine A110',' Alpine A310',' Alpine V6',' Avantime',' Clio',' Coupe',' Espace',' Express',' Fluence',' Fuego',' Grand Espace',' Grand Modus',' Grand Scenic',' Kangoo',' Koleos',' Laguna',' Latitude',' Mascott',' Master',' Megane',' Modus',' P 1400',' R 11',' R 14',' R 18',' R 19',' R 20',' R 21',' R 25',' R 30',' R 4',' R 5',' R 6',' R 9',' Rapid',' Safrane',' Scenic',' Spider',' Trafic',' Twingo',' Vel Satis',' Wind',' Other']; // Set Renault models
  model[77] = ['Corniche',' Flying Spur',' Ghost',' Park Ward',' Phantom',' Silver Cloud',' Silver Dawn',' Silver Seraph',' Silver Shadow',' Silver Spirit',' Silver Spur',' Other']; // Set Rolls Royce models
  model[78] = ['100',' 111',' 114',' 115',' 200',' 213',' 214',' 216',' 218',' 220',' 25',' 400',' 414',' 416',' 418',' 420',' 45',' 600',' 618',' 620',' 623',' 75',' 800',' 820',' 825',' 827',' City Rover',' Metro',' Montego',' SD',' Streetwise',' Other']; // Set Rover models
  model[79] = ['Other']; // Set Ruf models
  model[80] = ['9-3',' 9-4X',' 9-5',' 9-7X',' 90',' 900',' 9000',' 96',' 99','Other']; // Set Saab models
  model[81] = ['Other']; // Set Santana models
  model[82] = ['Alhambra',' Altea',' Arosa',' Cordoba',' Exeo',' Ibiza',' Inca',' Leon',' Malaga',' Marbella',' Terra',' Toledo','Other']; // Set Seat models
  model[83] = ['105',' 120',' 130',' 135',' Citigo',' Fabia',' Favorit',' Felicia',' Forman',' Octavia',' Pick-up',' Praktik',' Roomster',' Superb',' Yeti',' Other']; // Set Skoda models
  model[84] = ['Crossblade',' ForFour',' ForTwo',' Roadster',' Other']; // Set Smart models
  model[85] = ['C8',' C8 AILERON',' C8 DOUBLE 12 S',' C8 LAVIOLETTE SWB',' C8 SPYDER SWB',' Other']; // Set Spyker models
  model[86] = ['Actyon',' Family',' Korando',' Kyron',' MUSSO',' REXTON',' Rodius',' Other']; // Set Ssangyong models
  model[87] = ['B9 Tribeca',' Baja',' Forester',' Impreza',' Justy',' Legacy',' Libero',' OUTBACK',' SVX',' Trezia',' Tribeca',' Vivio',' XT',' Other',]; // Set Subaru models
  model[88] = ['Alto',' Baleno',' Cappuccino',' Carry',' Grand Vitara',' Ignis',' Jimny',' Kizashi',' Liana',' LJ',' SJ Samurai',' Splash',' Super-Carry',' Swift',' SX4',' Vitara',' Wagon R+',' X-90',' Other']; // Set Suzuki models
  model[89] = ['Horizon',' Samba',' Other']; // Set Talbot models
  model[90] = ['Indica',' Indigo',' Nano',' Safari',' Sumo',' Telcoline',' Telcosport',' Xenon',' Other']; // Set Tata models
  model[91] = ['Other']; // Set Tesla models
  model[92] = ['4-Runner',' Auris',' Avalon',' Avensis',' Avensis Verso',' Aygo',' Camry',' Carina',' Celica',' Corolla',' Corolla Verso',' Cressida',' Crown',' Dyna',' FJ',' Hiace',' Highlander',' Hilux',' IQ',' Land Cruiser',' Lite-Ace',' MR 2',' Paseo',' Picnic',' Previa',' Prius',' RAV 4',' Sequoia',' Sienna',' Starlet',' Supra',' Tacoma',' Tercel',' Tundra',' Urban Cruiser',' Verso',' Verso-S',' Yaris',' Other']; // Set Toyota models
  model[93] = ['601',' Other']; // Set Trabant models
  model[94] = ['Dolomite',' Moss',' Spitfire',' TR3',' TR4',' TR5',' TR6',' TR7',' TR8',' Other']; // Set Triumph models
  model[95] = ['Chimaera',' Griffith',' Tuscan',' Other']; // Set TVR models
  model[96] = ['181',' Amarok',' Beetle',' Bora',' Buggy',' Caddy',' Corrado',' Crafter',' Eos',' Fox',' Golf (All)',' Golf',' Golf Plus',' Iltis',' Jetta',' Karmann Ghia',' Käfer',' LT',' Lupo',' New Beetle',' Passat (All)',' Passat',' Passat CC',' Phaeton',' Polo',' Routan',' Santana',' Scirocco',' Sharan',' T1',' T2',' T3 (All)',' T3 Caravelle',' T3 Multivan',' T3 other',' T4 (All)',' T4 Caravelle',' T4 Multivan',' T4 other',' T5 (All)',' T5 Caravelle',' T5 Multivan',' T5 Shuttle',' T5 other',' Taro',' Tiguan',' Touareg',' Touran',' up!',' Vento',' Other']; // Set Volkswagen models
  model[97] = ['240',' 244',' 245',' 262',' 264',' 340',' 360',' 440',' 460',' 480',' 740',' 744',' 745',' 760',' 780',' 850',' 855',' 940',' 944',' 945',' 960',' 965',' Amazon',' C30',' C70',' Polar',' S40',' S60',' S70',' S80',' S90',' V40',' V50',' V60',' V70',' V90',' XC 60',' XC 70',' XC 90',' Other']; // Set Volvo models
  model[98] = ['311',' 353',' Other']; // Set Wartburg models
  model[99] = ['Other']; // Set Westfield models
  model[100] = ['MF 25',' MF 28',' MF 3',' MF 30',' MF 35',' MF 4',' MF 5',' Other']; // Set Wiesmann models

    var test = model[41][1];

    function setModel(index) {
        var modelDropdown = document.getElementById('model');
        modelDropdown.options.length = null;
        for(var i = 0; i < model[index].length; i++) {
            modelDropdown.options[i] = new Option(model[index][i],model[index][i]);
        }
    }

function setModel2(index) {
        var modelDropdown = document.getElementById('model2');
        modelDropdown.options.length = null;
        for(var i = 0; i < model[index].length; i++) {
            modelDropdown.options[i] = new Option(model[index][i],model[index][i]);
        }
    }

    window.onload = function() {
        var makeDropdown = document.getElementById('make');
        makeDropdown.onchange = function() {
            setModel(this.selectedIndex);
        }


	var makeDropdown2 = document.getElementById('make2');
        makeDropdown2.onchange = function() {
            setModel2(this.selectedIndex);
        }

    }

 

and heres the code for auto pre seleting the values when posted to form

 

if(isset($_GET['manufacturer'])){ $manufacturer = $_GET['manufacturer']; 
}elseif(isset($_POST['manufacturer'])){ $manufacturer = $_POST['manufacturer']; }

if(isset($manufacturer) && !empty($manufacturer)){

echo '<script type="application/javascript">
$(document).ready(function() {
	$("#make2 option[value=\''.$manufacturer.'\']").attr(\'selected\', \'selected\');
	$("#model2 option[value=\'Punto Evo\']").attr(\'selected\', \'selected\');
	var makeDropdown3 = document.getElementById(\'make2\');
        setModel2(makeDropdown3.selectedIndex);
});
</script>';

}

 

if you can sort this i will buy you a beer ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.