|
 |
|
 |
07-12-2004, 08:54 PM
|
#1 (permalink)
|
|
Registered User
Join Date: Jul 2004
Posts: 1
|
Multiple Entry Fields for One Database Field
Can someone please help me with the country chooser script below. i really need to have a seperate state field but have no idea how to add this. I have looked for other scripts that have Region/Country/State fields but have not been able to find any that are cross browser compatible. I plan to use the script in a membership application form which submits the info to a 'excel type' database. I should point out, I do not want to list states/provinces for every country (probably just for US/Canada & Australia) but would like to include the 'other' function where a user would enter his state/province if it was not listed, I would also need to this option for the country field as more than likely I wont have a complete country list.
I would really appreciate it if someone could point me in the direction of a script that does this or can advise me of the changes I need to make to 'country chooser' to get it to work this way
Thankx in advance
Csaba
Code:
<html>
<head><script LANGUAGE="JavaScript">
var africaArray = new Array("('Select country','',true,true)",
"('South Africa')",
"('Other')");
var middleeastArray = new Array("('Select country','',true,true)",
"('U. A. Emirates')",
"('Other')");
var asiaArray = new Array("('Select country','',true,true)",
"('Vietnam')",
"('Other')");
var europeArray = new Array("('Select country','',true,true)",
"('United Kingdom')",
"('Other')");
var australiaArray = new Array("('Select country','',true,true)",
"('Australia')",
"('New Zealand')",
"('Other')");
var lamericaArray = new Array("('Select country','',true,true)",
"('Panama')",
"('Other')");
var namericaArray = new Array("('Select country','',true,true)",
"('Canada')",
"('USA')",
"('Other')");
var samericaArray = new Array("('Select country','',true,true)",
"('Venezuela')",
"('Other')");
function populateCountry(inForm,selected) {
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.country.options.length) {
inForm.country.options[(inForm.country.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("inForm.country.options[i]=" + "new Option" + selectedArray[i]);
}
if (inForm.region.options[0].value == '') {
inForm.region.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
}
function populateUSstate(inForm,selected) {
var stateArray = new Array("('Select State','',true,true)",
"('West Virginia')",
"('Wisconsin')",
"('Wyoming')");
if (selected == 'USA') {
for (var i=0; i < stateArray.length; i++) {
eval("inForm.country.options[i]=" + "new Option" + stateArray[i]);
}
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0)
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0)
}
}
}
}
else {
}
if (selected == 'Other') {
newCountry = "";
while (newCountry == ""){
newCountry=prompt ("Please enter the name of your country.", "");
}
if (newCountry != null) {
inForm.country.options[(inForm.country.options.length-1)]=new Option(newCountry,newCountry,true,true);
inForm.country.options[inForm.country.options.length]=new Option('Other, not listed','Other');
}
}
if(inForm.country.options[0].text == 'Select country') {
inForm.country.options[0]= null;
}
}
</script>
<title>Country and Area</title>
</head>
<body>
<form name="globe">
<div align="center"><center><p><select name="region"
onChange="populateCountry(document.globe,document.globe.region.options[document.globe.region.selectedIndex].value)"
size="1">
<option selected value>Select Region</option>
<option value="asia">Asia</option>
<option value="africa">Africa</option>
<option value="australia">Australia</option>
<option value="europe">Europe</option>
<option value="middleeast">Middle East</option>
<option value="lamerica">Latin America</option>
<option value="namerica">North America</option>
<option value="samerica">South America</option>
</select> <select name="country"
onChange="populateUSstate(document.globe,document.globe.country.options[document.globe.country.selectedIndex].text)"
size="1">
</select></p>
</center></div>
</form>
</body>
</html>
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
SQL-Additional fields
|
fdtoo |
Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) |
0 |
08-28-2004 12:22 AM |
All times are GMT -8. The time now is 02:05 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|