Hello wisdoms,
Please have a glance on my following querry and attached reference files.
I need to make three combo box which are related to each other.When the user
choose the Continents,the specified countries should be displayed in the
pull down menu.For each countries we have facilities in the database,that
facilities should be displayed in the third pull down menu.

I Have the script for the first two combo boxes.No issues...When i tried to
link the third box through OnChange JavaScript function,there is null values
in the second box itself. we tried to bring the solution through the
following Perl scripts .

*ISSUES:*
Now when the user choose a country,the final country in the continent is
displayed as selected ie the following country override the previous
one...Example..the Turkey country is displayed as selected country what
ever we choose in the Europe Region........

Please guys ....I searched a lot in the Perl as well as JavaScripts
Forums.........Let ur valuable suggestion may bring a better solution to
this issue......Help me............Thanks.........


##########################################

my %Regions = (
 Europe =>[
   'Belgium',
   'Denmark',
   'France',
   'Germany',
   'Great Britain',
   'Hungary',
   'Portugal',
   'Russia',
   'Spain',
   'Sweden',
   'Turkey',
 ],
 Asia => [
   'Australia',
   'China',
   'India',
   'Malaysia',
   'NewZealand',
   'Philippines',
   'South Africa',
   'Taiwan',
   'Vietnam',
 ],
 North => [
   'U.S.',
   'Canada',
   'Mexico',
 ],

 South => [
   'Argentina',
   'Brazil',
   'Venezuela',
 ],
);

 foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[0]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Belgium" $selected >Belgium</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[1]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Denmark" $selected >Denmark</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[2]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="France" $selected >France</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[3]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Germany" $selected >Germany</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[4]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Great Britain" $selected >Great Britain</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[5]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Hungaryk" $selected >Hungary</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[6]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Portugal" $selected >Portugal</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[7]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Russia" $selected >Russia</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[8]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Spain" $selected >Spain</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[9]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Sweden" $selected >Sweden</option>
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe')
{$country_code="$Regions{$region}[10]"; my
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Turkey" $selected >Turkey</option>
######################################################
<script type="text/javascript">
 var countryLists = new Array(4) 
 countryLists["empty"] = ["Select a Country"]; 
 countryLists["North America"] = ["Canada", "United States", "Mexico"]; 
 countryLists["South America"] = ["Brazil", "Argentina", "Venezuela"]; 
 countryLists["Asia Pacific/Africa"] = 
["Australia","China","India","Malaysia","New Zealand","Philippines","South 
Africa","Taiwan","Vietnam"]; 
 countryLists["Europe"]= ["Belgium","Denmark","France","Germany","Great 
Britain","Hungary","Portugal","Russia","Spain","Sweden","Turkey"]; 
  
 function countryChange(selectObj) { 
 // get the index of the selected option 
 var idx = selectObj.selectedIndex; 
 // get the value of the selected option 
 var which = selectObj.options[idx].value; 
 // use the selected option value to retrieve the list of items from the 
countryLists array 
 cList = countryLists[which]; 
 // get the country select element via its known id 
 var cSelect = document.getElementById("country"); 
 // remove the current options from the country select 
 var len=cSelect.options.length; 
 while (cSelect.options.length > 0) { 
 cSelect.remove(0); 
 } 
 var newOption; 
 // create new options 
 for (var i=0; i<cList.length; i++) { 
 newOption = document.createElement("option"); 
 newOption.value = cList[i];  // assumes option string and value are the same 
 newOption.text=cList[i]; 
 // add the new option 
 try { 
 cSelect.add(newOption);  // this will fail in DOM browsers but is needed for 
IE 
 } 
 catch (e) { 
 cSelect.appendChild(newOption); 
 } 
 } 
 } 
//]]>
</script>
 my %Regions = (
 Europe =>[ 
   'Belgium',
   'Denmark',
   'France',
   'Germany',
   'Great Britain',
   'Hungary',
   'Portugal',
   'Russia',
   'Spain',
   'Sweden',
   'Turkey',
 ],
 Asia => [
   'Australia',
   'China',
   'India',
   'Malaysia',
   'NewZealand',
   'Philippines',
   'South Africa',
   'Taiwan',
   'Vietnam',
 ],
 North => [
   'U.S.',
   'Canada',
   'Mexico',
 ],

 South => [
   'Argentina',
   'Brazil',
   'Venezuela',
 ],
);



foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[0]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Belgium" $selected >Belgium</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[1]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Denmark" $selected >Denmark</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[2]"; my 
$selected="selected";}else{$selected="";}} 
print qq ~ <option value="France" $selected >France</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[3]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Germany" $selected >Germany</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[4]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Great Britain" $selected >Great Britain</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[5]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Hungaryk" $selected >Hungary</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[6]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Portugal" $selected >Portugal</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[7]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Russia" $selected >Russia</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[8]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Spain" $selected >Spain</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[9]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Sweden" $selected >Sweden</option> 
~;foreach my $region ( keys %Regions ) { if($region eq 'Europe') 
{$country_code="$Regions{$region}[10]"; my 
$selected="selected";}else{$selected="";}}
print qq ~ <option value="Turkey" $selected >Turkey</option> 
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/

Reply via email to