I have 3 dropdowns. Depending on the first i need to show different options in the 2nd and 3rd.
Options are known so to avoid AJAX i putted all the available options in the dropdown and gave them class names to be able to target the options. Example below:
First drop down:
<select name="language" id="language">
<option value="0" disabled="disabled" selected="selected">Select ...</option>
<option value="DA">Danish - DA</option>
<option value="EN">English - EN</option>
</select>
Second drop down: (.queryall is used to remove all the option when changing selection, .queryda is used to show all the option for Danish, .queryen is used to show all the option for English)
<select name="status" id="status">
<option value="0" disabled="disabled" selected="selected">Select ...</option>
<option class="queryall queryda">Answered</option>
<option class="queryall queryda queryen">Closed</option>
<option class="queryall queryen">Escalated</option>
</select>
jQuery:
<script>
$("#language").change(function() {
$("#status .queryall").hide();
$("#status .queryac").show();
alert("New Status options are available.");
});
</script>
Here is the question, how to pass a param “queryda” when changing language to Danish?
Thanks in advance.
Create folder called “jquery” inside “js”
Create in your “test.com” folder file called “index.html”
Alright, routine work finished, now to the code.
This is your “index.html” code:
This is your “main.css” code:
This is your “data.js” code:
And at last, the whole functionality, this is your “main.js” file:
Now, just navigate to your “index.html” file in your browser or use it on your local/remote web server and see the results :p
Enjoy, Bora!