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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help With Simple Dropdown Box Array

    Hello:

    I have a simple dropdown box like this:

    <select name="border">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="">Blank</option>
    </select>

    In fact i have lots of them and to same space I want to use arrays to generate them automaticly.

    I made this but it dosn't buil a dropdown or seprate Value/Text fields.

    <script language="JavaScript">
    var border = new Array(10);
    for(var i=0; i < border.length; i++ ){
    border[i]=i + 0;
    document.write(border[i] + "<br>");
    }
    </script>

    Anyone help?
    Thanks
    mossimo

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    do you mean this?
    Code:
    function buildSelect(name,max){
      var s = '<select name="'+name+'">\n';
      for (var i=0;i<max;i++) s+='<option value="'+i+'">'+i+'</option>\n';
      s+='<option value="">Blank</option>\n';
      s+='</select>';
      document.write(s);
    }
    
    ...
    
    <body>
    <form>
    <script type="text/javascript">buildSelect('border',9)</script>
    ...
    <script type="text/javascript">buildSelect('border2',9)</script>
    ...
    <script type="text/javascript">buildSelect('border3',9)</script>
    </form>

  • #3
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi mossimo,

    Or you could modify the code here:

    http://members.aol.com/grassblad/cascade3.html

    Vinny
    Where the world once stood
    the blades of grass
    cut me still

  • #4
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks glenngv

    Thats exactly what I was thinking works great.

    One more thing if you don't mind

    What's the correct way to add:
    <select name="border" style="width: 50px" onChange="updateStyle()">

    to:

    var s = '<select name="'+value+'">\n';


    Cheers
    mossimo
    Last edited by mossimo; 09-29-2003 at 07:41 PM.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    var s = '<select name="'+value+'" style="width: 50px" onChange="updateStyle()">\n';

  • #6
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Again


  •  

    Posting Permissions

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