This is designed to work specifically with SiteSpinner and WebEngine. It is not generic javascript code.
Loading form selector's with country and state (or providence) data is very time consuming. So here is a script that will do it for you. It is designed to populate the name and value options of two SiteSpinner form selection lists when the page loads. One list will hold country data and the other will hold state/providence data. In addition, the state selector is only visible when the selected country has state/providence data associated with it. (See the example below.)
After unzipping the populate-cs.js script file, upload it to your web site. To access the script from your page, include the following in a custom header:
<script type="text/javascript" src="populate-cs.js"></script>Usage
You will need to place two form selection lists on your work page. Double-click the first selection list and set the Name field to "countrySelect" (no quotes) and in the Code field enter:
onchange='populateState();'
This executes the javascript function to populate the state selection list when the country selection is changed. The state selection list is only populated and displayed if the selected country has state/providence data associated with it.
Double-click the second selection list and set the Name field to "stateSelect" (do not use the quotes). Now create a custom header and insert the following:
where form-name is the name of the form and default-country is the two letter country code you want to initially be displayed in the selection list (quotes are required). If you do not want a default country to be displayed, enter "" (an empty string).
If you want only the state/providence selection list visible (i.e., no country list), set the default country and use the SpecialFX Loading menu to hide the country selection list or use CSS code in a custom header hide the list.
Country and State Data
The country and state data is embedded in the populate-cs.js script file and is assigned to two variables: country for the country data and state for the state data. All data consists of strings that are concatenated together with special characters used as separators. The data is not sorted and is entered into the selection list as found in the file. If you find you need to modify the data, please follow the data format and enter the data where you want it to appear in the list.
Country data is entered as:
'country_code:country_name|' +
If the entry is the last in the list, replace the "+" (plus) with a ";" (semi-colon). The ":" (colon) is used to separate the country code value from the country name. The "|" (vertical bar) is used to separate the different country entries. The state data is similar, but contains an additional field:
'country_code:state_code:state_name|' +The additional field (country_code) is used by the script to identify the state date for the selected country. Only state data matching the selected data will be included in the selection list.
Contact the LowTechGeezer
VM User's Forum
Bruceee's Sandpit
Webmaster's Corner
Other Useful Sites
“Upload” means you will need to transfer the file from your computer to your web site. The most common method is to use an FTP program (such as the free Filezilla).
If you want to use SiteSpinner, then you can use the Embed File/Media tool button to add a Publish File object to your page (choose this in the Format drop-down menu), then use the Filepath button to locate and attach your file to the object. When you publish your project, files attached to Publish File object are uploaded to your site’s root folder.
i am unclear with your instructions: “After unzipping the populate-cs.js script file, upload it to your web site” do you mean download this to a page in sitespinner on the design pages? can you please help
Hi there. I am a user of Site Spinner and I, like some others seem to be having problems with forms, exactly like this one that I am using now.
Would you be able to add a tutorial that show how you made this “leave a comment’ form along with the others that you have listed in your ‘java script – forms’ section.
Thanks a lot,
Ken..