Results 1 to 2 of 2

Thread: Cross-browser compatibility issue

Hybrid View

  1. #1
    Join Date
    Jan 2009

    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:

    function populateCats() {
    	var opt = document.createElement("option");
    opt.text = "Visual Basic";
    opt.value = "5";
    var opt = document.createElement("option");
    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:

    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];
    		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,
    Last edited by Jester; 11-13-2009 at 09:23 PM.

  2. #2
    Join Date
    Jan 2009
    Nevermind all, I search and search - finally resort to posting on a forum, and then I find the problem. Seems IE is just a little more friendlier with using the "name" attribute as an ID for getElementById.

    Now just a CSS issue to figure out, and home and hosed

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