dfwalton
Programmer
- Jul 24, 2002
- 143
I am offering users pricing based on their State and County. I select the state, and onchange fire a script that returns the counties in the state for the user to select one.
Problem is that the form on the main script does not include the newly created "select" options. When I view "page info/forms" the "county" control is not in the list after I select a state.
[tt]<select name="stateID" id="stateID" onchange=
"javascript:getCountyList('getCounty.cfm?id='+this.value)">
<option value="0" selected >Choose a state</option>[/tt]
I put the results into this div:
[tt]<div id="txtResult"> <select name="County"><option value="0">Select a County</option></select> </div>[/tt]
The script I run selects the counties in the state, and loops through then to create <option> entries:
[tt]<select name="county" >
<option value='0'>Select County </option>
<cfloop query="getCounty">
<option onselect="document.searchform.hiddenCounty.value='#getCounty.locationID#'"
value="#getCounty.LocationId#">#getCounty.LocationName#</option>
</cfloop>
</select>[/tt]
I have tinkered extensively with this, doing it both with and without the opening <select> tag.
THe relevant javascript is:
[tt]
XMLHttpRequestObject.onreadystatechange= function()
{
if(XMLHttpRequestObject.readyState ==4 &&
XMLHttpRequestObject.status == 200){
document.getElementById("txtResult").innerHTML= XMLHttpRequestObject.responseText;
[/tt]
Problem is that the form on the main script does not include the newly created "select" options. When I view "page info/forms" the "county" control is not in the list after I select a state.
[tt]<select name="stateID" id="stateID" onchange=
"javascript:getCountyList('getCounty.cfm?id='+this.value)">
<option value="0" selected >Choose a state</option>[/tt]
I put the results into this div:
[tt]<div id="txtResult"> <select name="County"><option value="0">Select a County</option></select> </div>[/tt]
The script I run selects the counties in the state, and loops through then to create <option> entries:
[tt]<select name="county" >
<option value='0'>Select County </option>
<cfloop query="getCounty">
<option onselect="document.searchform.hiddenCounty.value='#getCounty.locationID#'"
value="#getCounty.LocationId#">#getCounty.LocationName#</option>
</cfloop>
</select>[/tt]
I have tinkered extensively with this, doing it both with and without the opening <select> tag.
THe relevant javascript is:
[tt]
XMLHttpRequestObject.onreadystatechange= function()
{
if(XMLHttpRequestObject.readyState ==4 &&
XMLHttpRequestObject.status == 200){
document.getElementById("txtResult").innerHTML= XMLHttpRequestObject.responseText;
[/tt]