Lately I’ve been trying to curb the overuse of AJAX. Basically it’s great that we can make all these calls to the server, but why make things so complicated. Why not just send all the data to the page and then handle it on the client side.
Thinking back to those kool
Hello World Hello Ajax demo’s we all did back in 05 I wanted to revisit the classic cascading drop down scenario.
I won’t bore you with the server side (use what every you want I)but here is the client side HTML.
The child dropdown contains all of the possible values and all options should initially be hidden. We are going to use the class of the option to store it’s parent ID. That is the key.
Then all we have to do is write a few lines of JQuery like this…
And that’s it.