Item in Listbox to display content in another listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chez
    New Member
    • May 2011
    • 9

    Item in Listbox to display content in another listbox

    Developement platform : Linux
    I'm using cgi.

    I have 2 listbox (<select>) on the same page.
    the first listbox will display all the item name(flat file) from a directory.
    the second listbox will then display the content of the selected items in first listbox to the second listbox once the item in first listbox is clicked or selected.

    below are my first listbox. i have no idea if that is correct or not.
    Code:
    @testList = `ls -1 /u/test/html/cgi-bin/tester/List`;
    
    
    print"<select multiple=\"multiple\">";
    for(@testList){
    $tester = $_; 
    print"<option>$tester</option>";
    }
    print"</select>";

    Pls advice and guide me through this. Thanks a lot
    Last edited by Meetee; May 11 '11, 06:18 AM. Reason: please use code tags [code][/code] around your code
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Add an onchange to the first listbox which calls a JavaScript function which would get all the selected options (opt.selected where opt is an option and selected is a property true/false).

    Use a for loop to loop over the options. To add options to the second listbox, you can use new Option(...) or the select add() method.

    This should be enough to get you started. If you get stuck, post your updated code.

    Comment

    Working...