SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    556
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How do i populate dropdown ?

    Hi,

    I have 2 dropdowns. In 1st dropdown (dd1) I have alphabets from A to Z. I want so that when someone selects alphabets from A to H then second dropdown i.e: (dd2) is filled with number from 1 to 20

    and

    If any alphabet from J to Z is selected in (dd1) then (dd2) is filled with number from 1 to 999.

    Please help.

    Thanks.

  2. #2
    doRighteousDeeds++
    Join Date
    Aug 2006
    Location
    تركيا Turkey Türkiye
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
      
    <script type="text/javascript">
    function fillOpt(v) {
    var el = document.getElementById('select0');
    var el2 = document.getElementById('select1');
    el2.options.length = 0;
    if(v > 8 ) {
    for(var i = 1; i< 1000 ; i++) { el2.options[i-1] = new Option(i,i); }
    }
    else {
    for(var i = 1; i< 21 ; i++) {   el2.options[i-1] = new Option(i,i);  }
    }
    }
    </script>
    <select id="select0" onchange="fillOpt(this.selectedIndex)">
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
    <option value="D">D</option>
    <option value="E">E</option>
    <option value="F">F</option>
    <option value="G">G</option>
    <option value="H">H</option>
    <option value="I">I</option>
    <option value="J">J</option>
    <option value="K">K</option>
    <option value="L">L</option>
    <option value="M">M</option>
    <option value="N">N</option>
    <option value="O">O</option>
    <option value="P">P</option>
    <option value="R">R</option>
    <option value="S">S</option>
    <option value="T">T</option>
    <option value="U">U</option>
    <option value="V">V</option>
    <option value="Y">Y</option>
    <option value="Z">Z</option>
    </select>
    
    <select id="select1">
    
    </select>


Bookmarks

Posting Permissions

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