Nikola Mikasinovic
04/12/2022, 12:37 PMaliaspooryorik
Nikola Mikasinovic
04/12/2022, 1:39 PMaliaspooryorik
aliaspooryorik
Nikola Mikasinovic
04/12/2022, 2:32 PMaliaspooryorik
aliaspooryorik
<!--- get the data for the first select box --->
<cfset optionsOne = DAO.selectOneData()>
<cfoutput>
<select name="a" id="selectone">
<cfloop array="#optionsOne#" index="option">
<option value="#encodeForHtmlAttribute(option.value)#">#encodeForHtml(option.label)#</option>
</cfloop>
</select>
<br>
<select name="b" id="selecttwo">
</select>
</cfoutput>
<script src="<https://code.jquery.com/jquery-3.6.0.min.js>" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$(function() {
$('#selectone').on('change', function() {
var selectValue = this.value;
// call the server to get data for the 2nd select
$.ajax({
method: "POST",
href: '/getdata.cfm',
data: {
selectValue: selectValue
}
}).done(function(data) {
// use the data the server returns to populate the 2nd select...
});
})
});
</script>
Peter Amiri
04/13/2022, 2:00 AM