Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
<script type="text/javascript">
$(document).ready(function() {
//first, detect when initial DD changes
$("#parent_select").change(function() {
//get what they selected
var selected = $("option:selected",this).val();
//no matter what, clear the other DD
$("#child_select").children().remove().end().append("<option value=\"\">Select Option</option>");
//now load in new options if I picked a state
if(selected == "") return;
$.getJSON("categories.cfc?method=getContactSubCategory&returnformat=json",{"ccatID":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].csubid + "\">" + res[i].contact_subcategory + "</option>";
}
$("#child_select").children().end().append(newoptions);
});
});
});
</script>
<select id="parent_select" name="parent_select">
<option value="">--</option>
<cfoutput query="getContactCategory">
<option value="#ccatID#">#contact_category#</option>
</cfoutput>
</select>
<br><br>
<b>Select issue details:</b><br>
<select id="child_select" name="child_select">
<option value="">Select Option</option>
</select>
JSON:
{"COLUMNS":["CSUBID","CONTACT_SUBCATEGORY","CATID"],"DATA":[[3,"Tracking shows delivered but shipment not received",1],[2,"Shipment is late",1],[4,"Product stuck in a courier",1],[5,"Other order issues",1],[1,"Check Status of my order",1]]}
for(var i=0; i<res.DATA.length; i++) {
//In our result, ID is what we will use for the value, and NAME for the label
newoptions += "<option value=\"" + res.DATA[i][0] + "\">" + res.DATA[i][1] + "</option>";
}
{
"COLUMNS": ["CSUBID", "CONTACT_SUBCATEGORY", "CATID"],
"DATA": [
[3, "Tracking shows delivered but shipment not received", 1],
[2, "Shipment is late", 1],
[4, "Product stuck in a courier", 1],
[5, "Other order issues", 1],
[1, "Check Status of my order", 1]
]
}
rs.DATA[i][0] //(the id)
//and
rs.DATA[i][1] //(the description).
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.