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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    133
    Thanks
    6
    Thanked 0 Times in 0 Posts

    My InnerHTML and drop down script does not work with Firefox and Opera

    Hi all,

    The following code works perfectly with IE but it doesn't work with Firefox and Opera. Do you have any idea about the possible reason ?

    Regards



    JavaScript Function part:

    <script language="JavaScript" type="text/javascript">
    function drawSelects(n){
    var fields = document.forms["Cal"].elements;
    if(n <= 3){
    for(var i = 1; i <= 10; i++){
    var newOpt = document.createElement("option");
    newOpt.text = i;
    newOpt.value = i;
    fields["sel" + n].options.add(newOpt);
    fields["sel" + n].onchange = function(){
    drawInputs(this.options[this.selectedIndex].value, this.options[0].text);
    }
    }
    n++;
    }
    else{return;}
    setTimeout("drawSelects(" + n + ")",50);
    }

    function drawInputs(k, user){
    document.getElementById(user).innerHTML = "";
    for(var i = 0; i < k; i++){
    var newInp = document.createElement("span");
    newInp.innerHTML="<input type=text class=style2 name="+ user + (i+1) + " title='"+ user + (i+1) + "' / >";
    document.getElementById(user).appendChild(newInp);
    document.getElementById(user).innerHTML += "&nbsp;&nbsp;&nbsp;<br />";
    }
    }

    function clearForm(){
    document.getElementById("newFields").innerHTML = "<div id=\"adults\"><\/div><div id=\"children\"><\/div><div id=\"infants\"><\/div>";
    }
    </script>


    HTML Part:

    <table align="center" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td height="44"><div align="left"><span class="style2">Other Adults:</span>
    <select id="sel1" name="sel1" class="style2">
    <option value="adults">Adults</option>
    </select>
    </div></td>
    <td height="44"><div align="left"><span class="style2">Children(3-12): </span>
    <select id="sel2" name="sel2" class="style2">
    <option value="children">Children</option>
    </select>
    </div></td>
    <td height="44"><div align="left"><span class="style2">Infants(0-2): </span>
    <select id="sel3" name="sel3" class="style2">
    <option value="infants">Infants</option>
    </select>
    </div></td>
    </tr>
    <tr>
    <td colspan="3" valign="top">
    <tr>
    <td valign="top" width="168"><div align="center" id="adults" runat="server" class="style2"></div> </td>
    <td valign="top" width="168"><div align="center" id="children" runat="server" class="style2"></div></td>
    <td valign="top" width="168"><div align="right" id="infants" runat="server" class="style2"></div></td>
    </tr>
    </table>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    <div id=\"adults\"><\/div><div id=\"children\"><\/div><div id=\"infants\"><\/div>
    Why those \s ?
    PS: innerHTML() is not a standard DOM method to create something; use createElement() instead.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Apr 2006
    Posts
    133
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks for the reply. I didn't write the code. I am not good at javascript. They helped me with writing this script on the Javascript forums. I don't have any idea how I can edit as you said.
    Could you send me an example code?

    Thanks
    telmessos


  •  

    Posting Permissions

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