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 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    urgetn - need help generating drop down (unlimited)

    Hi guys,

    This is a the current code which generates unlimited text boxes.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <script language="JavaScript" type="text/javascript">
    var noRows=0;

    function addTextBox(select){
    var ids = ['roomtype','datestart','dateend','rate'];
    var container = document.getElementById('TextBoxes');
    var nu = select.options[select.selectedIndex].value;
    for(;nu--;noRows++){
    for(var k=0,id; id=ids[k]; k++)
    container.appendChild(createTextBox(id+noRows));
    container.appendChild(document.createElement('br'));
    }
    }

    function createTextBox(id)
    {
    var box = document.createElement('input');
    box.type = 'text';
    box.size = '15';
    box.id = box.name = id;
    return box;
    }
    </script></head>

    <body>
    <form name="form" action="index2.php" method="post">
    <select name="AddTextBox" size="1" onchange="addTextBox(this);" >
    <option value="0">Add row</option>
    <option value="1">One Row</option>
    <option value="2">Two Row</option>
    <option value="3">Three Row</option>
    <option value="4">Four Row</option>
    </select>

    <div id="TextBoxes" ></div>
    <input type="submit">

    </body>
    </html>

    What I would like to do is along with the text boxes I would like to generate a a drop down box with the values (single,double,triple, quadruple).


    How can it be done?

    Thanks
    Apurva M

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    That new drop dow box should be the same, nomatter of the selected option in your first drop? I mean, always will be generated the same structured drop down box? Or?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes the drop box will have only static data as in it just needs to be genrated along with the textboxes thats all..

    NO events will occur/values will change when a item is selected from a drop box. It should act as a regular drop box.

    Thanks
    Apurva

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try something like this:
    PHP Code:
    function addTextBox(select){
    var 
    ids = ['roomtype','datestart','dateend','rate'];
    var 
    container document.getElementById('TextBoxes');
    var 
    nu select.options[select.selectedIndex].value;
    for(;
    nu--;noRows++){
    for(var 
    k=0,idid=ids[k]; k++)
    container.appendChild(createTextBox(id+noRows));
    container.appendChild(document.createElement('br'));
    }
    var 
    oSel document.createElement{'select')
    var 
    sVal =[single,double,triple,quadruple];
    oSel.setAttribute('name','sel'+nu);
    for(var 
    i=0;i<sVal.length;i++){
    var 
    oOpt document.createElement('option');
    var 
    oTxt document.createTextNode(sVal[i]);
    oOpt.setAttribute('value',sVal[i]);
    oOpt.appendChild(oTxt);
    oSel.appendChild(oOpt);
    }
    container.appendChild(oSel);
    container.appendChild(document.createElement('br'));

    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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