Results 1 to 4 of 4

Thread: multiple chain select box

  1. #1
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default multiple chain select box

    hey guys i want to make a multiple select box mixed with mysql?

    cause all the ones i found hade some jquery and ajax in it.

    see i need the first box to contain the trainers name and when you select the trainer the second box gets the clients in his databse.is that possible?

  2. #2
    Join Date
    Sep 2008
    Posts
    56
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re:- multiple chain select box

    Hi,
    Yes this is very much possible with JS or Ajax. The Logic to be implemented will be there will be one array of the trainers and multiple arrays of clients. There will be one array of clients for each trainer. You will have to trap the onChange event of the trainers multiple select box and call a JS function. This JS function will be passed the value of the trainer clicked, if the trainer is being selected then pick the respective array of clients and populate it in the clients select box and if its being de-selected then remove from the clients select box the clients of the un-selected trainer.

    Hope this helps.

    Cheers,
    ~Maneet Puri

  3. #3
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    are you looking for something like this?
    <script type="text/javascript">
    function SelOpt(getID){
    var Content = document.getElementById("client");
    var sel = Content.getElementsByTagName("select");
    Content.reset();
    for (var i = 0; i < sel.length; i++){
    sel[i].style.display = (sel[i].getAttribute("id") == getID) ? "inline" : "none";
    }}
    onload = function(){
    SelOpt("s0");
    }
    </script>

    <select OnChange="SelOpt(this.value);" OnKeyUp="SelOpt(this.value);">
    <option value="s0">select trainer</option>
    <option value="s1">trainer 1</option>
    <option value="s2">trainer 2</option>
    <option value="s3">trainer 3</option>
    <option value="s4">trainer 4</option>
    </select>

    <form Id="client">
    <span id="s0">&nbsp;</span>
    <select id="s1">
    <option selected>select 1 client 1</option>
    <option>select 1 client 2</option>
    <option>select 1 client 3</option>
    </select>
    <select id="s2">
    <option selected>select 2 client 1</option>
    <option>select 2 client 2</option>
    <option>select 2 client 3</option>
    </select>
    <select id="s3">
    <option selected>select 3 client 1</option>
    <option>select 3 client 2</option>
    <option>select 3 client 3</option>
    </select>
    <select id="s4">
    <option selected>select 4 client 1</option>
    <option>select 4 client 2</option>
    <option>select 4 client 3</option>
    </select>
    </form>
    Last edited by jscode; 11-02-2009 at 07:35 AM.

  4. #4
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    exactly.thats cool.i think do there is a mistake cause it stops at the second box.

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
  •