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 11 of 11
  1. #1
    New Coder
    Join Date
    Jun 2014
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts

    is this a bug ?...

    I dont think so !


    and theres no code mistakes , it seems...



    i assign selections to drop-down menus ( <select></select> ) using document.getElementById("ID").innerHTML= "something" ,

    it works until now for a 4th drop down, it wont show the values...

    ive checked and checked my code.

    i dont find what the tweak is .



  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,308
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by franc11 View Post
    I dont think so !


    and theres no code mistakes , it seems...



    i assign selections to drop-down menus ( <select></select> ) using document.getElementById("ID").innerHTML= "something" ,

    it works until now for a 4th drop down, it wont show the values...

    ive checked and checked my code.

    i dont find what the tweak is .



    How can you possibly expect anyone to give you a sensible answer?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    you would normally change a select programmatically using its .selectedIndex or .value, not the innerHTML, which may work but may also bring unexpected results

  • Users who have thanked xelawho for this post:

    franc11 (06-22-2014)

  • #4
    New Coder
    Join Date
    Jun 2014
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    you would normally change a select programmatically using its .selectedIndex or .value, not the innerHTML, which may work but may also bring unexpected results
    I use an id for each option. the case i am at is theres is more than 30s ids .


    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <script>
    
    var subtypes=["Hot","Temperate","Cold","Gas Giant"]; 
    var atmosphere=["Toxic","Breathable","No Atmosphere"];
    var sizes=["1x1","2x2","3x3","4x4","5x5","6x6","7x7","8x8","9x9","10x10","11x11","12x12","13x13","14x14","15x15","16x16","17x17","18x18","19x19","20x20","30x30","none"];
    
    
    
    function myfunction1(celestral){
    alert(celestral);
    if(celestral==1){
    alert(sizes[1]);
    document.getElementById("8").innerHTML= subtypes[0]  ;
    document.getElementById("9").innerHTML= subtypes[1]  ;
    document.getElementById("10").innerHTML= subtypes[2]  ;
    document.getElementById("11").innerHTML= subtypes[3]  ;
    document.getElementById("12").innerHTML= "Subtype: ";
    document.getElementById("13").style.visibility= 'visible';
    document.getElementById("menu2").style.visibility= 'visible';
    document.getElementById("21").innerHTML= sizes[3] ;
    document.getElementById("22").innerHTML= sizes[4];
    document.getElementById("23").innerHTML= sizes[5];
    document.getElementById("24").innerHTML= sizes[6];
    document.getElementById("25").innerHTML= sizes[7];
    document.getElementById("26").innerHTML= sizes[8];
    document.getElementById("27").innerHTML= sizes[9];
    document.getElementById("28").innerHTML= sizes[10];
    document.getElementById("29").innerHTML= sizes[11];
    document.getElementById("30").innerHTML= sizes[12];
    document.getElementById("31").innerHTML= sizes[13];
    document.getElementById("32").innerHTML= sizes[14];
    document.getElementById("33").innerHTML= sizes[15];
    document.getElementById("34").innerHTML= sizes[16];
    document.getElementById("35").innerHTML= sizes[17];
    document.getElementById("36").innerHTML= sizes[18];
    document.getElementById("37").innerHTML= sizes[19];
    }else if(celestral==2){ 
    document.getElementById("8").innerHTML= null;
    document.getElementById("9").innerHTML= null;
    document.getElementById("10").innerHTML= null;
    document.getElementById("11").innerHTML= null;
    document.getElementById("12").innerHTML= null;
    document.getElementById("13").style.visibility= 'hidden';
    document.getElementById("14").innerHTML= null;
    document.getElementById("menu2").style.visibility= 'hidden';
    document.getElementById("21").innerHTML= sizes[0];
    document.getElementById("22").innerHTML= sizes[1];
    document.getElementById("23").innerHTML= sizes[2];
    }else if(celestral==3){ 
    document.getElementById("8").innerHTML= null;
    document.getElementById("9").innerHTML= null;
    document.getElementById("10").innerHTML= null;
    document.getElementById("11").innerHTML= null;
    document.getElementById("12").innerHTML= null;
    document.getElementById("13").style.visibility= 'hidden';
    document.getElementById("14").innerHTML= null;
    document.getElementById("menu2").style.visibility= 'hidden';
    document.getElementById("21").innerHTML= sizes[20];
    }else if(celestral==4){ 
    document.getElementById("8").innerHTML= null;
    document.getElementById("9").innerHTML= null;
    document.getElementById("10").innerHTML= null;
    document.getElementById("11").innerHTML= null;
    document.getElementById("12").innerHTML= null;
    document.getElementById("13").style.visibility= 'hidden';
    document.getElementById("14").innerHTML= null;
    document.getElementById("menu2").style.visibility= 'hidden';
    document.getElementById("21").innerHTML= sizes[0];
    }else if(celestral==5){ 
    document.getElementById("8").innerHTML= null;
    document.getElementById("9").innerHTML= null;
    document.getElementById("10").innerHTML= null;
    document.getElementById("11").innerHTML= null;
    document.getElementById("12").innerHTML= null;
    document.getElementById("13").style.visibility= 'hidden';
    document.getElementById("14").innerHTML= null;
    document.getElementById("menu2").style.visibility= 'hidden';
    document.getElementById("21").innerHTML= sizes[0];
    }else if(celestral==6){ 
    document.getElementById("8").innerHTML= null;
    document.getElementById("9").innerHTML= null;
    document.getElementById("10").innerHTML= null;
    document.getElementById("11").innerHTML= null;
    document.getElementById("12").innerHTML= null;
    document.getElementById("13").style.visibility= 'hidden';
    document.getElementById("14").innerHTML= null;
    document.getElementById("menu2").style.visibility= 'hidden';
    document.getElementById("21").innerHTML= sizes[21];
    }
    }
    function myfunction2(subtype1){
    if((subtype1==8)||(subtype1==9)||(subtype1==10) ){
    alert(subtype1);
    document.getElementById("14").innerHTML= " Atmosphere ";
    document.getElementById("15").innerHTML= atmosphere[0] ;
    document.getElementById("16").innerHTML= atmosphere[1] ;
    document.getElementById("17").innerHTML= atmosphere[2] ;
    document.getElementById("menu2").style.visibility= "visible";
    }else{
    document.getElementById("14").innerHTML= null;
    document.getElementById("15").innerHTML= null;
    document.getElementById("16").innerHTML= null;
    document.getElementById("17").innerHTML= null;
    document.getElementById("menu2").style.visibility= "hidden";
    }
    }
    
    
    </script>
    <table>
    <thead><p>Swcombine Planet Creator v1</p></thead>
    <thead>Generate a planet !</thead>
    <form name="form1">
    <tr><td>Celestral Body</td><td>
    <select name="Celestral" id="celestral" onChange="myfunction1(this.value);";>
        <option value=1>Planet</option>
        <option value=2>Moon</option>
        <option value=3>Sun</option>
        <option value=4>Asteroid Field</option>
        <option value=5>Comet</option>
        <option value=6>Black Hole</option>
        </select>
    </td></tr>
    <tr><td><p id="12"></p></td><td>
      <select name="subtype" onChange="myfunction2(this.value);" id="menu1">
        <option value="8" id="8"></option>
        <option value="9" id="9"></option>
        <option value="10" id="10"></option>
        <option value="11" id="11"></option>
      </select></td>
    </tr>
    
    <tr><td><p id="14"></p></td><td>
      <select name="atmosphere" onChange="MM_jumpMenu('parent',this,0)" id="menu2">
        <option id="15"></option>
    	<option id="16"></option>
    	<option id="17"></option>
    	<option id="18"></option>
      </select>
    
    </td></tr>
    <tr> <td><p id="20">Size:</p></td> 
    <td><select name="sizes" onChange="MM_jumpMenu('parent',this,0)" id="hoho">
      <option id="21" value="21"></option>
      <option id="22" value="22"></option>
      <option id="23" value="23"></option>
      <option id="24" value="24"></option>
      <option id="25" value="25"></option>
      <option id="26" value="26"></option>
      <option id="27" value="27"></option>
      <option id="28" value="28"></option>
      <option id="29" value="29"></option>
      <option id="30" value="30"></option>
      <option id="31" value="31"></option>
      <option id="32" value="32"></option>
      <option id="33" value="33"></option>
      <option id="34" value="34"></option>
      <option id="35" value="35"></option>
      <option id="36" value="36"></option>
      <option id="37" value="37"></option>
      <option id="38" value="38"></option>
      <option id="39" value="39"></option>
      <option id="40" value="40"></option>
      <option id="41" value="41"></option>
      <option id="42" value="42"></option>
    </select>
    </td></tr>
     
     
     
    <tr><td>//grid here//</td>
    
    
    
    
    
    
    </form>
    </table>
    </body>
    </html>

  • #5
    New Coder
    Join Date
    Jun 2014
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    ignores some of the alarm() here and there, just copy and paste the code and see that the ''size'' drop-down doesnt shows up values, while other drop-downs does

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    Quote Originally Posted by franc11 View Post
    and theres no code mistakes , it seems...

    yes, there are mistakes a-plenty. Check your error console

  • #7
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    Quote Originally Posted by franc11 View Post
    ignores some of the alarm() here and there, just copy and paste the code and see that the ''size'' drop-down doesnt shows up values, while other drop-downs does
    what are you hoping that this bit will do:
    Code:
    onChange="MM_jumpMenu('parent',this,0)"
    ?

  • #8
    New Coder
    Join Date
    Jun 2014
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    what are you hoping that this bit will do:
    Code:
    onChange="MM_jumpMenu('parent',this,0)"
    ?
    it does that by default. my bug console doesnt report anyhting odd ..

  • #9
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    you need to use a different error console, and look at it while interacting with your page. I'm using the console in Chrome and I see errors every time I change a dropdown

  • #10
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    It would be more readable to work with an astronomical object constructor !
    You have to build objects with different properties according to the categories cats=["sun","planet","satellite","asteroid","comet","black hole"];

    Then to build dynamicaly a drop-down list use the Option constructor (see for exemple Changing Select element content on the fly)
    Last edited by 007julien; 06-22-2014 at 12:34 PM.

  • Users who have thanked 007julien for this post:

    franc11 (06-22-2014)

  • #11
    New Coder
    Join Date
    Jun 2014
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    hey thanks julien, that is a fresh code here.


    sorry for being kinda fast triggered, i will try to improve my code as further on . its a liuttle program i do for a website.


    ty


  •  

    Posting Permissions

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