onChange ComboBox javascripts not working on Firefox but works fine on IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shailen21
    New Member
    • Jul 2008
    • 4

    onChange ComboBox javascripts not working on Firefox but works fine on IE

    Hi everybody,
    Im trying to use that piece of javascripts for 2 combo box in my web site but its nt working on Firefox but it works well in IE 6.0 :S
    Can someone please help me in solving this problem.
    I included the js functions.
    The first ComboBox is when the user select an option the URL must may be a pop up and the second ComboBox needs to open the URL within the page itself.
    Both are using the onChange() function.

    Thanks for a quick reply or solutions ;)

    The codes are as follows:


    => included in the <head>

    Code:
    <script type="text/javascript">
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      if (theURL != "") {
      window.open(theURL,winName,features);
      }
    }
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    </script>
    
    ------------------
    
    <body>....
    
    <select name="select" class="booking" onChange="MM_openBrWindow(this.options(this.selectedIndex).value,'bookwindow','')">
                  <option selected="selected">--------</option>
                  <option value="http://www.google.com">1</option>
                  <option value="http://www.google.com">2</option>
                  <option value="http://www.google.com">3</option>
                  <option value="http://www.google.com">4</option>
                  <option value="http://www.google.com">5</option>
                </select>
    
    ------------- 
    
    
    <select name="select2" class="booking" onChange="MM_goToURL('parent',this.options(this.selectedIndex).value);return document.MM_returnValue">
                  <option selected="selected" value="#">--------</option>
                  <option value="http://www.google.com">1</option>
                  <option value="http://www.google.com">2</option>
                  <option value="http://www.google.com">3</option>
                  <option value="http://www.google.com">4</option>
                  <option value="http://www.google.com">5</option>
                </select>
    Last edited by acoder; Jul 18 '08, 10:14 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    First mistake: testing in IE first.

    IE is sometimes lax on syntax. options is an array, so you need square brackets [], not round brackets/parentheses (), i.e. options[...]

    Please enclose your code using code tags.

    Comment

    • shailen21
      New Member
      • Jul 2008
      • 4

      #3
      Originally posted by acoder
      First mistake: testing in IE first.

      IE is sometimes lax on syntax. options is an array, so you need square brackets [], not round brackets/parentheses (), i.e. options[...]

      Please enclose your code using code tags.

      Ooops sorry about the codes...
      You are right to say TESTING IN IE FIRST IS VERY BIG MISTAKES ...
      IE really S...ks if u work wiz CSS 2.0 !!!

      Well i will try ur suggestion n come back to give more details..
      thanks anyway :)

      Comment

      • shailen21
        New Member
        • Jul 2008
        • 4

        #4
        Originally posted by acoder
        First mistake: testing in IE first.

        IE is sometimes lax on syntax. options is an array, so you need square brackets [], not round brackets/parentheses (), i.e. options[...]

        Please enclose your code using code tags.
        can you please give me an example using the above codes of the proposed solution using array instead of () ...

        thanks

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Either:[html]<select name="select" class="booking" onchange="MM_op enBrWindow(this .options[this.selectedIn dex].value,'bookwin dow','')">[/html]or [html]<select name="select" class="booking" onchange="MM_op enBrWindow(this .value,'bookwin dow','')">[/html]this.value is a shortcut.

          Comment

          • shailen21
            New Member
            • Jul 2008
            • 4

            #6
            Originally posted by acoder
            Either:[html]<select name="select" class="booking" onchange="MM_op enBrWindow(this .options[this.selectedIn dex].value,'bookwin dow','')">[/html]or [html]<select name="select" class="booking" onchange="MM_op enBrWindow(this .value,'bookwin dow','')">[/html]this.value is a shortcut.
            Damn it ... u r great :D
            I was with that with more than 2 hrs ... loolllllzzz


            It works :D

            Thanks a lot ;)

            many thanks again

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              You're welcome. Pleased it's now working.

              Comment

              Working...