Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts

    Dynamic Option list error in FF

    I'm using Matt Kruse's Dynamic Option list script here
    http://www.footballhangout.com/Stats/xmlstart12.html

    It works fine in IE and I don't really understand how to apply the error I get in Firefox.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    bump, anyone?

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have various problems going on. You have some case issues like you had 'game' in some places and 'Game' in others. Also you were using game and xmlname as DynamicOptionList objects when they weren't (that is actually what was causing the parsing errors in FF). The actual object was names.

    Although the page seems to work now you are still going to have problems on submit in FF with your Ajax and xml/xsl since it does things a different way. You might want to look into a cross platform library to make things similar like zXml which can be downloaded from here

    http://www.nczonline.net/downloads/

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script language="Javascript" type="text/javascript" src="http://www.footballhangout.com/Stats/dynamicoptionlist.js"></script>
    
    <script language="Javascript" type="text/javascript">
    function picker(){ 
    var WeekField = document.getElementById('Week');
    var gameField = document.getElementById('game');
    var xmlnameField = document.getElementById('xmlname');
    var seasonField = document.getElementById('Season');
    alert("Get stats for: " + seasonField.value +  WeekField.value + xmlnameField.value)
    var xml = new ActiveXObject("Microsoft.XMLDOM")
    xml.async = false
    xml.load("http://www.footballhangout.com/Stats/" + seasonField.value + WeekField.value + "/" + xmlnameField.value + ".xml")// Load XSL
    var xsl = new ActiveXObject("Microsoft.XMLDOM")
    xsl.async = false
    xsl.load("testsimple.xsl")// Transform
    document.write(xml.transformNode(xsl))
    }
    </script>
    
    </head>
    
    <body onLoad="initDynamicOptionLists()">
    
    <form>
    <script language="Javascript" type="text/javascript">
    var names = new DynamicOptionList("Week","game","xmlname"); 
    names.forValue("Week1").addOptions("Miami 17 at Pittsburgh 28", "Atlanta 20 at Carolina 6", "Baltimore 27 at Tampa Bay 0", "Buffalo 17 at New England 19", "Cincinnati 23 at Kansas City 10", "Denver 10 at St. Louis 18", "New Orleans 19 at Cleveland 14", "N.Y. Jets 23 at Tennessee 16", "Philadelphia 24 at Houston 10", "Seattle 9 at Detroit 6", "Chicago 26 at Green Bay 0", "Dallas 17 at Jacksonville 24", "San Francisco 27 at Arizona 34", "Indianapolis 26 at N.Y. Giants 21", "Minnesota 19 at Washington 16", "San Diego 27 at Oakland 0");
    names.forValue("Week2").addOptions("Buffalo 16 at Miami 6", "Carolina 13 at Minnesota 16 (OT)", "Cleveland 17 at Cincinnati 34", "Detroit 7 at Chicago 34", "Houston 24 at Indianapolis 43", "New Orleans 34 at Green Bay 27", "N.Y. Giants 30 at Philadelphia 24 (OT)", "Oakland 6 at Baltimore 28", "Tampa Bay 3 at Atlanta 14", "Arizona 10 at Seattle 21", "St. Louis 13 at San Francisco 20", "Kansas City 6 at Denver 9", "New England 24 at N.Y. Jets 17", "Tennessee 7 at San Diego 40", "Washington 10 at Dallas 27", "Pittsburgh 0 at Jacksonville 9");
    names.forValue("Week3").addOptions("Carolina 26 at Tampa Bay 24", "Chicago 19 at Minnesota 16", "Cincinnati 28 at Pittsburgh 20", "Green Bay 31 at Detroit 24", "Jacksonville 14 at Indianapolis 21", "N.Y. Jets 28 at Buffalo 20", "Tennessee 10 at Miami 13", "Washington 31 at Houston 15", "Baltimore 15 at Cleveland 14", "N.Y. Giants 30 at Seattle 42", "Philadelphia 38 at San Francisco 24", "St. Louis 16 at Arizona 14", "Denver 17 at New England 7", "Atlanta 3 at New Orleans 23");
    names.forValue("Week4").addOptions("Arizona 10 at Atlanta 32", "Dallas 45 at Tennessee 14", "Indianapolis 31 at N.Y. Jets 28", "Miami 15 at Houston 17", "Minnesota 12 at Buffalo 17", "New Orleans 18 at Carolina 21", "San Diego 13 at Baltimore 16", "San Francisco 0 at Kansas City 41", "Detroit 34 at St. Louis 41", "Cleveland 24 at Oakland 21", "Jacksonville 30 at Washington 36 OT", "New England 38 at Cincinnati 13", "Seattle 6 at Chicago 37", "Green Bay 9 at Philadelphia 31");
    names.forValue("Week5").addOptions("Buffalo 7 at Chicago 40", "Cleveland 12 at Carolina 20", "Detroit 17 at Minnesota 26", "Miami 10 at New England 20", "St. Louis 23 at Green Bay 20", "Tampa Bay 21 at New Orleans 24", "Tennessee 13 at Indianapolis 14", "Washington 3 at N.Y. Giants 19", "Kansas City 23 at Arizona 20", "N.Y. Jets 0 at Jacksonville 41", "Oakland 20 at San Francisco 34", "Dallas 24 at Philadelphia 38", "Pittsburgh 13 at San Diego 23", "Baltimore at Denver 8:30 p.m.");
    names.forField("xmlname").forValue("Week1").forValue("Miami 17 at Pittsburgh 28").addOptions("miapit");
    names.forField("xmlname").forValue("Week1").forValue("Atlanta 20 at Carolina 6").addOptions("atlcar");
    names.forField("xmlname").forValue("Week1").forValue("Baltimore 27 at Tampa Bay 0").addOptions("baltam")
    names.forField("xmlname").forValue("Week1").forValue("Buffalo 17 at New England 19").addOptions("bufne");
    names.forField("xmlname").forValue("Week1").forValue("Cincinnati 23 at Kansas City 10").addOptions("cinkan");
    names.forField("xmlname").forValue("Week1").forValue("Denver 10 at St. Louis 18").addOptions("denstl");
    names.forField("xmlname").forValue("Week1").forValue("New Orleans 19 at Cleveland 14").addOptions("nocle");
    names.forField("xmlname").forValue("Week1").forValue("N.Y. Jets 23 at Tennessee 16").addOptions("nyjten");
    names.forField("xmlname").forValue("Week1").forValue("Philadelphia 24 at Houston 10").addOptions("phihou");
    names.forField("xmlname").forValue("Week1").forValue("Seattle 9 at Detroit 6").addOptions("seadet");
    names.forField("xmlname").forValue("Week1").forValue("Chicago 26 at Green Bay 0").addOptions("chigre");
    names.forField("xmlname").forValue("Week1").forValue("Dallas 17 at Jacksonville 24").addOptions("daljac");
    names.forField("xmlname").forValue("Week1").forValue("San Francisco 27 at Arizona 34").addOptions("sanari");
    names.forField("xmlname").forValue("Week1").forValue("Indianapolis 26 at N.Y. Giants 21").addOptions("indnyg");
    names.forField("xmlname").forValue("Week1").forValue("Minnesota 19 at Washington 16").addOptions("minwas");
    names.forField("xmlname").forValue("Week1").forValue("San Diego 27 at Oakland 0").addOptions("sanoak");
    names.forField("xmlname").forValue("Week2").forValue("Detroit 7 at Chicago 34").addOptions("detchi");
    names.forField("xmlname").forValue("Week2").forValue("Houston 24 at Indianapolis 43").addOptions("houind");
    names.forField("xmlname").forValue("Week2").forValue("New Orleans 34 at Green Bay 27").addOptions("nogre");
    names.forField("xmlname").forValue("Week2").forValue("N.Y. Giants 30 at Philadelphia 24 OT").addOptions("nygphi");
    names.forField("xmlname").forValue("Week2").forValue("Oakland 6 at Baltimore 28").addOptions("oakbal");
    names.forField("xmlname").forValue("Week2").forValue("Tampa Bay 3 at Atlanta 14").addOptions("tamatl");
    names.forField("xmlname").forValue("Week2").forValue("Arizona 10 at Seattle 21").addOptions("arisea");
    names.forField("xmlname").forValue("Week2").forValue("St. Louis 13 at San Francisco 20").addOptions("stlsan");
    names.forField("xmlname").forValue("Week2").forValue("Kansas City 6 at Denver 9").addOptions("kanden");
    names.forField("xmlname").forValue("Week2").forValue("New England 24 at N.Y. Jets 17").addOptions("nenyj");
    names.forField("xmlname").forValue("Week2").forValue("Tennessee 7 at San Diego 40").addOptions("tensd");
    names.forField("xmlname").forValue("Week2").forValue("Washington 10 at Dallas 27").addOptions("wasdal");
    names.forField("xmlname").forValue("Week2").forValue("Pittsburgh 0 at Jacksonville 9").addOptions("pitjac"); 
    names.forField("xmlname").forValue("Week2").forValue("Buffalo 16 at Miami 6").addOptions("bufmia");
    names.forField("xmlname").forValue("Week2").forValue("Carolina 13 at Minnesota 16 OT").addOptions("carmin");
    names.forField("xmlname").forValue("Week2").forValue("Cleveland 17 at Cincinnati 34").addOptions("clecin");
    names.forField("xmlname").forValue("Week3").forValue("Carolina 26 at Tampa Bay 24").addOptions("cartam");
    names.forField("xmlname").forValue("Week3").forValue("Chicago 19 at Minnesota 16").addOptions("chimin");
    names.forField("xmlname").forValue("Week3").forValue("Cincinnati 28 at Pittsburgh 20").addOptions("cinpit");
    names.forField("xmlname").forValue("Week3").forValue("Green Bay 31 at Detroit 24").addOptions("gredet");
    names.forField("xmlname").forValue("Week3").forValue("Jacksonville 14 at Indianapolis 21").addOptions("jacind");
    names.forField("xmlname").forValue("Week3").forValue("N.Y. Jets 28 at Buffalo 20").addOptions("nyjbuf");
    names.forField("xmlname").forValue("Week3").forValue("Tennessee 10 at Miami 13").addOptions("tenmia");
    names.forField("xmlname").forValue("Week3").forValue("Washington 31 at Houston 15").addOptions("washou");
    names.forField("xmlname").forValue("Week3").forValue("Baltimore 15 at Cleveland 14").addOptions("balcle");
    names.forField("xmlname").forValue("Week3").forValue("N.Y. Giants 30 at Seattle 42").addOptions("nygsea");
    names.forField("xmlname").forValue("Week3").forValue("Philadelphia 38 at San Francisco 24").addOptions("phisf");
    names.forField("xmlname").forValue("Week3").forValue("St. Louis 16 at Arizona 14").addOptions("stlari");
    names.forField("xmlname").forValue("Week3").forValue("Denver 17 at New England 7").addOptions("denne");
    names.forField("xmlname").forValue("Week3").forValue("Atlanta 3 at New Orleans 23").addOptions("atlno");
    names.forField("xmlname").forValue("Week4").forValue("Arizona 10 at Atlanta 32").addOptions("ariatl");
    names.forField("xmlname").forValue("Week4").forValue("Dallas 45 at Tennessee 14").addOptions("dalten");
    names.forField("xmlname").forValue("Week4").forValue("Indianapolis 31 at N.Y. Jets 28").addOptions("indnyj");
    names.forField("xmlname").forValue("Week4").forValue("Miami 15 at Houston 17").addOptions("miahou");
    names.forField("xmlname").forValue("Week4").forValue("Minnesota 12 at Buffalo 17").addOptions("minbuf");
    names.forField("xmlname").forValue("Week4").forValue("New Orleans 18 at Carolina 21").addOptions("nocar");
    names.forField("xmlname").forValue("Week4").forValue("San Diego 13 at Baltimore 16").addOptions("sdbal");
    names.forField("xmlname").forValue("Week4").forValue("San Francisco 0 at Kansas City 41").addOptions("sfkan");
    names.forField("xmlname").forValue("Week4").forValue("Detroit 34 at St. Louis 41").addOptions("detstl");
    names.forField("xmlname").forValue("Week4").forValue("Cleveland 24 at Oakland 21").addOptions("cleoak");
    names.forField("xmlname").forValue("Week4").forValue("Jacksonville 30 at Washington 36 OT").addOptions("jacwas");
    names.forField("xmlname").forValue("Week4").forValue("New England 38 at Cincinnati 13").addOptions("necin");
    names.forField("xmlname").forValue("Week4").forValue("Seattle 6 at Chicago 37").addOptions("seachi");
    names.forField("xmlname").forValue("Week4").forValue("Green Bay 9 at Philadelphia 31").addOptions("grephi");
    names.forField("xmlname").forValue("Week5").forValue("Buffalo 7 at Chicago 40").addOptions("bufchi");
    names.forField("xmlname").forValue("Week5").forValue("Cleveland 12 at Carolina 20").addOptions("clecar");
    names.forField("xmlname").forValue("Week5").forValue("Detroit 17 at Minnesota 26").addOptions("detmin");
    names.forField("xmlname").forValue("Week5").forValue("Miami 10 at New England 20").addOptions("miane");
    names.forField("xmlname").forValue("Week5").forValue("St. Louis 23 at Green Bay 20").addOptions("stlgre");
    names.forField("xmlname").forValue("Week5").forValue("Tampa Bay 21 at New Orleans 24").addOptions("tamno");
    names.forField("xmlname").forValue("Week5").forValue("Tennessee 13 at Indianapolis 14").addOptions("tenind");
    names.forField("xmlname").forValue("Week5").forValue("Washington 3 at N.Y. Giants 19").addOptions("wasnyg");
    names.forField("xmlname").forValue("Week5").forValue("Kansas City 23 at Arizona 20").addOptions("kanari");
    names.forField("xmlname").forValue("Week5").forValue("N.Y. Jets 0 at Jacksonville 41").addOptions("nyjjac");
    names.forField("xmlname").forValue("Week5").forValue("Oakland 20 at San Francisco 34").addOptions("oaksf");
    names.forField("xmlname").forValue("Week5").forValue("Dallas 24 at Philadelphia 38").addOptions("dalphi");
    names.forField("xmlname").forValue("Week5").forValue("Pittsburgh 13 at San Diego 23").addOptions("pitsd");
    names.forField("xmlname").forValue("Week5").forValue("Baltimore at Denver 8:30 p.m.").addOptions("balden");
    </script>
    </select>
    <select name="Week" id="Week" style="font-size:9pt;font-family:Century Gothic;color:DCDCDC;background-color:black;">
    <option value="Week1">Week 1</option>
    <option value="Week2">Week 2</option>
    <option value="Week3">Week 3</option>
    <option value="Week4">Week 4</option>
    <option value="Week5">Week 5</option>
    </select>
    <select name="game" id="game">
    <script language="Javascript" type="text/javascript">names.printOptions("game");</script>
    </select>
    <select name="xmlname" id="xmlname" onChange="names.change(this)">
    <script language="Javascript" type="text/javascript">names.printOptions("xmlname");</script>
    </select>
    <input type="hidden" id="Season" value="2007"><br>
    <input type="button" onclick="picker(this)" value="Get stats">
    </form>
    
    
    
    </body>
    </html>
    Note, the whole script was too long to post so I reduced it down to 5 weeks so you have to add back the other 12 weeks.

    david_kw

  • #4
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    First reason this code does not work in firefox is because in IE the string that you pass to getElementById is case-insensitive unlike firefox which is fiercely case-sensitive

    The next reason is the most obvious one. Firefox DOES NOT support ActiveX objects !! The easiest cross-browser solution to loading xml documents is the XMLHttpRequest's responseXML. Please use a javascript library like prototype (available here http://prototypejs.org/) to make it easier.

    to that add some utility functions given below
    Code:
    function loadXml(url) {
    	return new Ajax.Request(url, {method:'get', asynchronous:false}).transport.responseXML;
    }
    function serializeToString(xd) {
    	var r = '';
    	try {
    		if ( window.XMLSerializer ) {
    			var xs = new XMLSerializer();
    			return xs.serializeToString(xd);
    		} else if ( window.ActiveXObject ) {
    			return xd.xml;
    		}
    	} catch (e) {
    		alert(e);
    	}
    	return r;
    }
    function xslTransform(xml, xsl) {
    	var r = '';
    	try {
    		if ( window.XSLTProcessor ) {
    			var xp = new XSLTProcessor();
    			xp.importStylesheet(xsl, 'text/xsl');		
    			r = xp.transformToDocument(xml);
    			r = serializeToString(r);
    		} else if ( window.ActiveXObject ) {
    			r = xml.transformNode(xsl);
    		}
    	} catch(e) {
    		alert(e);
    	}
    	return r;
    }
    and your picker function will look like
    Code:
    function picker(){ 
    
    	alert("Get stats for: " + $F('week') +  $F('game') + $F('xmlname'));
    	var xml = loadXml('http://www.footballhangout.com/Stats/' + $F('Season') + $F('week') + "/" + $F('xmlname') + ".xml")// Load XSL
    	var xsl = loadXml("testsimple.xsl");// Transform
    	document.write(serializeToString(xslTransform(xml, xsl)));
    }
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

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