SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot bensheard's Avatar
    Join Date
    Jun 2006
    Location
    Cape Town | South Africa
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Menu works in IE but not in netscape

    Hi
    I have the following code:
    Code:
    <html>
    <head>
    <script type = 'text/javascript'>
    <!--
    
    var locations = Object();
    locations["9¶Barra Reef"] = "|1¶Buddys|6¶Salon|7¶Mike&#039;s Cupboard|8¶Crech";
    locations["8¶Fish Hoek"] = "|2¶Fish Hoek Station";
    locations["6¶Port Alfred"] = "|4¶Fish Tanks|5¶Soft Coral Reef";
    locations["7¶Simons Town"] = "|3¶Long Beach|16¶Klan Stuart|17¶A-Frame";
    locations["15¶Rooi Els"] = "|15¶The Balcony";
    locations["24¶Ile St Marie"] = "|23¶La Crique";
    locations["25¶Ile Aux Nattes"] = "|25¶Maningory";
    var loc_id, loc_txt, loc_array;
    function setLocations()
    {
    	for (region in locations)
    			{
    
    			loc_array = region.split('¶');
    			loc_id = loc_array[0];
    			loc_txt = loc_array[1];
    			document.write('<option value=`' + loc_id + '`>' + loc_txt + '</option>');
    			}
    }
    
    function set_site()
    {
    		var locationArr,siteArr;
    	document.f.site.length = 0;
    	
    	var region = document.f.location.options[document.f.location.selectedIndex].text;
    		var region2 = document.f.location.options[document.f.location.selectedIndex].value;
    		var region3 = region2 + '¶' + region;
    	if (locations[region3])
    	{ 
    		document.f.site.disabled = false;
    		document.f.site.options[0] = new Option('--Select Site--','');
    		locationArr = locations[region3].split('|');
    		for (var i = 0; i < (locationArr.length -1); i++)
    						{
    						siteArr = locationArr[i+1].split('¶');
    			document.f.site.options[i + 1] = new Option(siteArr[1], siteArr[0]);
    			}
    	
    		}else document.f.site.disabled = true;
    }
    
    //--></script>
    
    </head>
    <body>
    <form name="f">
    Location: <select name="location" onchange="set_site()">
    <script type="text/javascript">
    setLocations();
    </script>
    </select><br>
    Site: <select name="site"></select>
    </body>
    </html>
    It is used to update a second drop down menu after selecting a value from the first. It works perfectly in Internet Explorer but not in netscape. The first menu displays options but the second doesnt update. I have gone through my book and cant find anything about this. I must be missing something.

    Thanks
    Ben Sheard
    -------------
    Log all your dives easily and quickly from anywhere in the world
    www.divinglogs.cafe150.com

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What Netscape version? And what does the JavaScript Console tell you?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •