Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- //first, detect when initial DD changes
- $("##Account_Code").change(function() {
- //get what they selected
- var selected = $("option:selected",this).val();
- console.log("Selected:" + selected);
- //no matter what, clear the other DD
- //Tip taken from: http://stackoverflow.com/questions/47824/using-core-jquery-how-do-you-remove-all-the-options-of-a-select-box-then-add-on
- $("##Sub_Account_Code").children().remove().end().append("<option value=\"\">Select a Sub Account Code</option>");
- //now load in new options if I picked a state
- if(selected == "") return;
- $.getJSON("getAccountCodes.cfc?method=getSubAccountCodes&returnformat=json",{"account_code_id":selected}, function(res,code) {
- var newoptions = "";
- for(var i=0; i<res.length; i++) {
- //In our result, ID is what we will use for the value, and NAME for the label
- newoptions += "<option value=\"" + res[i].Account_Code_ID + "\">" + res[i].Account_Code + "</option>";
- $("##Sub_Account_Code").children().end().append(newoptions);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement