Can anyone help. Im trying to create 2 drop down lists (using the select tag). Based on the choice of the first drop down list the second list is populated.
You need to generate a piece of dynamic html - ie. produced on the fly, often referred to as AJAX.
which, in turn, performs am HTML "GET" to call another script on your server,
which returns data to make up the contents of the next <select>,
which must reside inside a DIV of its own, so you can replace its innerHTML.
Look up getHTTPObject for starters.
This instantiates an HTTP object, with which you
"open" the "GET" on your remote script,
"send" to obtain the response, and
define an "onreadystatechange" property to call another function to do stuff with your result... when it gets back to you.
Its not as hard as it sounds. Debugging a mistake; now that's hard - and can take you hours !
Some notes. I use "document.getElementById" to obtain existing data from the form that <select> resides in - to send parameters to my remote script.
Also, if I need to populate more than 1 DIV with my resulting data, I concatenate each part with a pipe ("|"), and then "split" it in my statechange function into an array and populate each DIV (hard coded names) with subsequent array elements.
Bit terse, but I hope that helps.
@vibha-nice code....and that too with quite well explanation...
Being that Im only just starting to learn php (and python) AJAX, JS all seems a bit daunting.
I have, however, come across the following code which is (pretty much) what Im looking for.
The only thing is, is that I need to add an additional 2 drop lists which are populated based on the select of the "Platform" list.
The code I have so far is :