www.webdeveloper.com
Results 1 to 2 of 2

Thread: Cross-browser compatibility issue

Threaded View

  1. #1
    Join Date
    Jan 2009
    Posts
    40

    Arrow Cross-browser compatibility issue

    Hey group,

    Hope someone can help me. My web site I'm currently building - everything is working ace in IE7, but seems every other browser has problems with both the javascript and CSS template I've got.

    So one thing at a time, I have the following code to populate categories to a combo box:

    Code:
    function populateCats() {
    	var opt = document.createElement("option");
    document.getElementById("CatSel").options.add(opt);
    opt.text = "Visual Basic";
    opt.value = "5";
    var opt = document.createElement("option");
    document.getElementById("CatSel").options.add(opt);
    opt.text = "PHP";
    opt.value = "3";
    }
    And when it's clicked on (and the intial page loading), it runs the following code to switch the sub-categories:

    Code:
    function switchCat(category, subCategory, blnLoad) {
    	var i;
    	var Cats = new Array(1);
    Cats[0] = new Array(3);
    Cats[0][0] = "Visual Basic";
    Cats[0][1] = "10#@#Functions";
    Cats[0][2] = "12#@#Methods";
    Cats[0][3] = "14#@#Constants";
    Cats[1] = new Array(2);
    Cats[1][0] = "PHP";
    Cats[1][1] = "16#@#Classes";
    Cats[1][2] = "17#@#Tutorials";
    	document.mainform.SubCatSel.options.length = 0;
    	for (i=0;i<Cats.length;i++) {
    		if (Cats[i][0] == category) { var index = i; break; }	
    	}
    	for (i=1;i<Cats[index].length;i++) {
    		var opt = document.createElement("option");
    		valSplit = Cats[index][i].split("#@#");
    		valID = valSplit[0];
    		valText = valSplit[1];
    		document.getElementById("SubCatSel").options.add(opt);
    		opt.text = valText;
            opt.value = valID;
            if ((blnLoad === true) && (valID == subCategory)) {
    	        var y = i;
            }
    	}
    	if ((blnLoad === true) && (subCategory != null)) {
    		document.getElementById("SubCatSel").options.selectedIndex = (y - 1);
    	}
    }
    It's a little crude, but constructed on the page load from a PHP/MySQL script I made.

    It works on IE7, but other browsers like Chome and Safari, doesn't seem to... (I haven't been able to test on IE8 yet). Can someone explain why, or how I can alter it slightly to behave?

    Thanks in advance,
    Jesse.
    Last edited by Jester; 11-13-2009 at 08:23 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles