Re: Populate Select List from JS
Hello everyone, So yesterday I figured out the JavaScript for my two selects. In the JS code below I have the information I need, Resort Name and Resort ID: script type = text/javascript function setOptions(opt) { var resortID = document.adminForm.resortID; resortID.options.length = 0; if ((opt == 0) || (opt == 1)){ resortID.options[resortID.options.length] = new Option(); } if ((opt == 2) || (opt == 2)) { cfoutput query=qSelectResorts resortID.options[resortID.options.length] = new Option('#Resort_Name#','#resort_ID#'); /cfoutput} } /script Here are the select lists: select name=adminID size=1 style=width: 150px onchange=setOptions(document.adminForm.adminID.options[document. adminForm.adminID.selectedIndex].value); option value=0 selectedSelect.../option option value=1Site Admin/option option value=2Resort Admin/option /select br / br / select name=resortID size=1 style=width: 150px option value = 0 /option/select The first list is hard coded as you can see and teh second one is dynamic. When you select Resort Admin then the second list populates with the resort names. What I need now is to get the resort ID's in the value and I don't know how to do that. If anyone can help me with this last part I would really appreciate it. Thanks in advance, Bruce ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352180 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Populate Select List from JS
Hello everyone, So yesterday I figured out the JavaScript for my two selects. In the JS code below I have the information I need, Resort Name and Resort ID: script type = text/javascript function setOptions(opt) { var resortID = document.adminForm.resortID; resortID.options.length = 0; if ((opt == 0) || (opt == 1)){ resortID.options[resortID.options.length] = new Option(); } if ((opt == 2) || (opt == 2)) { cfoutput query=qSelectResorts resortID.options[resortID.options.length] = new Option('#Resort_Name#','#resort_ID#'); /cfoutput} } /script Here are the select lists: select name=adminID size=1 style=width: 150px onchange=setOptions(document.adminForm.adminID.options[document. adminForm.adminID.selectedIndex].value); option value=0 selectedSelect.../option option value=1Site Admin/option option value=2Resort Admin/option /select br / br / select name=resortID size=1 style=width: 150px option value = 0 /option/select The first list is hard coded as you can see and teh second one is dynamic. When you select Resort Admin then the second list populates with the resort names. What I need now is to get the resort ID's in the value and I don't know how to do that. If anyone can help me with this last part I would really appreciate it. Thanks in advance, Bruce AJAX might be better here. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352181 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Populate Select List from JS
Actually this code worked once I corrected the spelling of a variable. Sorry I did not update the list. BRuce Bruce AJAX might be better here. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352182 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Populate Select List from JS
Hello everyone, So yesterday I figured out the JavaScript for my two selects. In the JS code below I have the information I need, Resort Name and Resort ID: script type = text/javascript function setOptions(opt) { var resortID = document.adminForm.resortID; resortID.options.length = 0; if ((opt == 0) || (opt == 1)){ resortID.options[resortID.options.length] = new Option(); } if ((opt == 2) || (opt == 2)) { cfoutput query=qSelectResorts resortID.options[resortID.options.length] = new Option('#Resort_Name#','#resort_ID#'); /cfoutput} } /script Here are the select lists: select name=adminID size=1 style=width: 150px onchange=setOptions(document.adminForm.adminID.options[document.adminForm.adminID.selectedIndex].value); option value=0 selectedSelect.../option option value=1Site Admin/option option value=2Resort Admin/option /select br / br / select name=resortID size=1 style=width: 150px option value = 0 /option/select The first list is hard coded as you can see and teh second one is dynamic. When you select Resort Admin then the second list populates with the resort names. What I need now is to get the resort ID's in the value and I don't know how to do that. If anyone can help me with this last part I would really appreciate it. Thanks in advance, Bruce ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352119 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm