javascript forms

JavaScript related questions should go here.
Post Reply
jonathon
Posts: 50
Joined: Fri May 06, 2011 5:09 pm

javascript forms

Post by jonathon »

Hi,

I have been trying to find an example of a form liek that on autotrader http://www.autotrader.co.uk/. Basically say you pick a car make as BMW, then the next field will only populate BMW models. So once you've selected input 1, input 2 is filtered for you. I must not be searching for it very well in Google as I can't find any examples. I'd just like to see how it's done.

Does anyone have any good links?

Thanks
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: javascript forms

Post by jacek »

You need to make an AJAX request, to get all of the makes of car based on the selection. Then use this to populate the second box.

So using the cars example you would probably make a request to something.php?make=BMW where BMW would come from the selection. something.php would output a JSON encoded array which you would decode and use to fill in the next box.

Try searching for "javascript auto populate select" or something similar.
Image
jonathon
Posts: 50
Joined: Fri May 06, 2011 5:09 pm

Re: javascript forms

Post by jonathon »

Thanks Jacek,

Found a couple of examples. I knew what technologies were used and roughly how do it, but my searching was pretty bad. thanks :)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: javascript forms

Post by jacek »

It's quite a common thing, you did pretty well to not find anything :lol:
Image
jonathon
Posts: 50
Joined: Fri May 06, 2011 5:09 pm

Re: javascript forms

Post by jonathon »

Thats what I was thinking. I put it down to it being late :lol:
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: javascript forms

Post by jacek »

jonathon wrote:Thats what I was thinking. I put it down to it being late :lol:
I was just about to record a tutorial :lol: Lets see how well that goes
Image
jonathon
Posts: 50
Joined: Fri May 06, 2011 5:09 pm

Re: javascript forms

Post by jonathon »

Haha,

Do it! I do enjoy your freestyling. Especially when you've got an afflication like a cold :lol: Kudos
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: javascript forms

Post by jacek »

jonathon wrote:Do it! I do enjoy your freestyling
Its a basics one too, no preperation :D
Image
jonathon
Posts: 50
Joined: Fri May 06, 2011 5:09 pm

Re: javascript forms

Post by jonathon »

It wouldn't be the same if you didn't get to 9 minutes and decide that you'd talked for a long time and then regretted it ;)
Post Reply