Code works fine in IE, but not in Firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    Code works fine in IE, but not in Firefox

    I'm having problem with this code in firefox but in the Internet Explorer Browser works fine on it what is the wrong in my code ?


    [HTML]<html>
    <head>
    <title>Like_mai l</title>
    <script type="text/javascript">
    //----------------------------------------------------------------------
    function addEvent()
    {
    var hidden = document.getEle mentById('theVa lue');
    var num = hidden.value++;
    var ni = document.getEle mentById('menu' );
    var divIdName = "menu_items"+nu m;
    var newdiv = document.create Element('div');
    newdiv.setAttri bute("id",divId Name);
    newdiv.innerHTM L ="<div class='menu_ite ms'><select name='select' id='select'><op tion>- Select State -</option></select><select name='select2' id='select2'><o ption>- Select Collage -</option></select><select name='select3' id='select3'><o ption>- Select Faculty -</option></select>&nbsp;&n bsp;&nbsp;&nbsp ;<input name='delete' type='button' id='delete' value='Delete' onclick='del_di vtag("+divIdNam e+")'/></div>"
    ni.appendChild( newdiv);
    }
    //----------------------------------------------------------------------
    function del_divtag(divI dName){
    var d = document.getEle mentById('menu' );
    var olddiv = document.getEle mentById(divIdN ame);
    d.removeChild(d ivIdName);
    }
    //----------------------------------------------------------------------
    </script>
    </head>
    <body>
    <div id="all">
    <div id="Dbanner">
    <input name="add" type="button" id="add" value="Add" onclick="addEve nt()"/>
    </div>
    <div id="menu">
    <div id="menu_banner ">
    <span style="margin-left:10px;" >| States |</span>
    <span style="margin-left:90px;" >| Collage |</span>
    <span style="margin-left:90px;" >| Faculty |</span>
    <input type="hidden" value="0" id="theValue" /></div>
    </div>
    </div>
    </body>
    </html>[/HTML]
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Changed the thread title.

    You're using document.all. That's not going to work in most browsers. Either use document.getEle mentById for one element or in the case of checkboxes, you coud use document.getEle mentsByName (using the name of the checkboxes). One other alternative is to use document.getEle mentsByTagName( "input"), but then you'd have to check the type too, because "input" has many types.

    Comment

    • smartic
      New Member
      • May 2007
      • 150

      #3
      thank you for replay but please check the code again i'v changed the code, my proplem is when i click on the delete button it dosn't work on the firefox

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        you should use and escape double-quotes for the onclick and make a correct stringop, replace the onclick-part you have with the following:

        Code:
        onclick='del_divtag(\"" + divIdName + "\")'
        kind regards

        Comment

        Working...