Web pages do not have an on-going connection to the server, so normally all information must be downloaded on the initial response. You have three options:
The most straightforward solution to your problem is to split the required functionality in two pages. In the first page the user will enter the state info. When the form is submitted to the server, a second script will return a page with the county selection form.
Alternatively, if the total number of counties is manageable, you can have all client codes and names be downloaded as a JavaScript array in your initial response. You can use the code field's onchange event to display the appropriate counties when the user selects a state. This solution is more elegant, but requires the use of JavaScript (and possibly DHTML) and is harder to implement.
Finally, if the number of counties is too large, in which case you would not want to send the full selection set for the whole country, then you can implement a 3rd solution, which involves a hidden frame (a frame with 0 width or height). The OnChange event of the state selection drop-down list would call a FoxWeb script in the hidden frame, passing the selected state to the script in the query string portion of the URL:
Drop-down list HTML:
<select name="state"
OnClick="stateOnClick(this.options[this.options.selectedIndex].value)">
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option> ... |
On-change event code:
function stateOnClick(stateAbbrev) {
top.hiddenFrame.href.location='GetCounties.fwx?state=' + stateAbbrev;
} |
The GetCounties.fwx script would then have to return a page containing JavaScript code, which would populate the counties drop-down list in the original frame.
Another variation of this solution, but which only works with Microsoft IE, was sent by our user
Oleg Goncharuk:
There is another solution, but you will require to limit your end-users with
MS IE5 and higher browser.
This browser includes built-in support for XML ActiveX object and this ActiveX allows to create XMLHTTPRequest object. You can write script:
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("GET", "http://anyhost/sample.fwx?parameters", false); xmlhttp.send(); xmlobj = new ActiveXObject("Msxml2.XMLDocument"); xmlobj.loadXML(xmlhttp.responseXML.xml) |
Alternatively you can use XML islands (you need only to change src attribute of tag <xml> to get new value)
Be sure that foxweb program must return "text/xml" instead of "text/html" content type.
Then you can freely use methods of XML object to build HTML code of your lookup from resulting data.
FoxWeb Support Team support@foxweb.com email |
Sent by Ronald Olds on 06/26/2002 10:55:01 AM:
I am creating a page that has a form on it that collects address information. I would like to have a drop down textbox contain all the 2 letter codes for the different states, when the user picks a state, I would like another drop down textbox be updated with all the counties for the selected state. Can anyone help me with this.
TIA
Ron