SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Non-Member leonte's Avatar
    Join Date
    Jul 2004
    Location
    Dubai
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Linked select menus

    I want to have two linked systems like this one over here: http://javascript.internet.com/forms...swapper-2.html

    So i have 4 boxes in total - 2 for selecting cities, and 2 for selecting distributors.
    So let`s name this boxes:
    Box A - the first box where all the city from my DB are.
    Box B - the second box where the user chosen cities are
    Box C - the first box from distributors - this box contains (this is the most important box) the distributors which are located in the cities listed in BOX B !!
    Box D - the second box from distributors - which contains the distributors chosen by the user.

    It`s hard to explain. So bear with me please. First the user sees Box A - the other boxes are all empty. He selects from Box A city X, after this city X appears in Box B, and all the distributors that can be found in city X appear in Box C aswell. So the user adds another city - more distributors appear in Box C. He adds several distributors from Box C to Box D and now he decides he doesn`t want city X anymore, so he Selects city X from Box B and transfers it back to Box A - now dynamically all distributors that were from city X are gone from Box D.

    I`m sure this looks completly impossible - but it is very important that i implement this - or some other system that is VERY user friendly.
    I use PHP and MySQL DB. I don`t kow JS.
    Again - i saw the boxes thing here: http://javascript.internet.com/forms...swapper-2.html

    I would really appreciate your help,
    thanks in advance,
    Mihai

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don`t kow JS.
    What help? Free web programming services? Transfer $400 to my Paypal account and I'll get started.

  3. #3
    Non-Member leonte's Avatar
    Join Date
    Jul 2004
    Location
    Dubai
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is this a freelancer site ? last time i checked it wasn`t
    I asked politely for help - if you don`t want/know to help please move on.
    This sounds too complicated for you - you want 400$ for something like this ?
    I want a simple suggestion - or some tip if this can be done... Not the source code for the whole thing.

    i thought guys like you existed only in my country - it`s a shock to see the world is full of your type...

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This sounds too complicated for you - you want 400$ for something like this ?
    I'm sorry, you must have misunderstood. That's a good faith deposit for me to start work--the full bill would be around $800.

    I want a simple suggestion
    I don`t kow JS.
    Learn javascript. That will be $5: 7stud@paypal.com

  5. #5
    Non-Member leonte's Avatar
    Join Date
    Jul 2004
    Location
    Dubai
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i`m poor - i can`t send you 5$

    please go away and let other persons help me if they want... are you trying to destroy my post ?

  6. #6
    SitePoint Member KPinAF's Avatar
    Join Date
    Feb 2005
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I am a bit confused. You provided a link to source code for exactly what you want, are you having problems with a certain section of code? I am sorry, but your original post does sound like you just want someone to code it for you. If you could be more specific as to what you are having trouble with, I will gladly try and be of help.

  7. #7
    Non-Member leonte's Avatar
    Join Date
    Jul 2004
    Location
    Dubai
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when two people says you're drunk you better go to sleep
    then i must apologize - i don`t want people do code it for me i want help with the Box B to Box C display.
    A: all cities -> B: selected cities
    C: all distributors from the selected cities -> D: selected distributors

    How do i link B and C - so when cities appear in box b - distributors appear in C... if B contains 3 cities - C contains distributors from those 3 cities.

  8. #8
    Non-Member leonte's Avatar
    Join Date
    Jul 2004
    Location
    Dubai
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    up

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ive done C, have a go at D


    PHP Code:
    new fnctions and arrays

    var Array12=new Array('DistA','DistB','DistC','DistD')
    var 
    Array54=new Array('DistE','DistF','DistG','DistH')
    var 
    Array65=new Array('DistI','DistJ','DistK','DistL')

    function 
    Populate(f,t){
     if (
    f.selectedIndex==-1){
      
    alert('not done'); return;
     }
     
    Ary=eval('Array'+(f.options[f.selectedIndex].value));
     for (
    i=0;i<t.options.length;i++){
      for (
    i1=0;i1<Ary.length;i1++){
       if (
    t.options[i].text==Ary[i1]){
        return
       }
      }
     }
     for (
    i2=0;i2<Ary.length;i2++){
      
    t.options[t.options.length]=new Option(Ary[i2],i2,true,true);
     }
    }

    function 
    Remove(s,f){
     if (
    f.selectedIndex<0||f.options.length<1){ return; }
     
    Ary=eval('Array'+(s.options[s.selectedIndex].value));
     
    OptionAry=new Array();
     
    document.Show.Show2.value=f.options.length;
     
    Cnt=0;
     for (
    i=0;i<f.options.length;i++){
      Use=
    1;
      for (
    i1=0;i1<Ary.length;i1++){
       if (
    f.options[i].text==Ary[i1]){
        Use=
    0;
       }
      }
      if (Use){
       
    OptionAry[Cnt]=new Array();
       
    OptionAry[Cnt][0]=f.options[i].text;
       
    OptionAry[Cnt][1]=f.options[i].value;
       
    Cnt++;
      }
     }
     
    f.options.length=0;
     for (
    i2=0;i2<OptionAry.length;i2++){
      
    f.options[f.options.length]=new Option(OptionAry[i2][0],OptionAry[i2][1],true,true);
     }


    PHP Code:
    Ammended HTML

    <form name="combo_box">
    <
    table><tr><td>
    <
    select multiple size="10" name="list1" style="width:150">
    <
    option value="12">Alabama</option>
    <
    option value="54">Alaska</option>
    <
    option value="65">Arizona</option>
    </
    select>
    </
    td>
    <
    td align="center" valign="middle">
    <
    input type="button" onClick="Remove(this.form.list2,this.form.list3);move(this.form.list2,this.form.list1)" value="<<">
    <
    input type="button" onClick="move(this.form.list1,this.form.list2)" value=">>">
    </
    td>
    <
    td>
    <
    select multiple size="10" name="list2" style="width:150">
    </
    select>
    </
    td>
    <
    td align="center" valign="middle">
    <
    input type="button" onClick="Populate(this.form.list2,this.form.list3)" value=">>">
    </
    td>
    <
    td>
    <
    select multiple size="10" name="list3" style="width:150">
    </
    select>
    </
    td>
    </
    tr>
    </
    table>

    </
    form

  10. #10
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was an easy fix. No changes were made to the function.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <style type='text/css'>
    select {
      width:150px;
    }
    </style>
    <script type='text/javascript'>
    function move(fbox, tbox)
    {
      var arrFbox = new Array();
      var arrTbox = new Array();
      var arrLookup = new Array();
      var i;
      for (i = 0; i < tbox.options.length; i++) {
        arrLookup[tbox.options[i].text] = tbox.options[i].value;
        arrTbox[i] = tbox.options[i].text;
      }
      var fLength = 0;
      var tLength = arrTbox.length;
      for(i = 0; i < fbox.options.length; i++) {
        arrLookup[fbox.options[i].text] = fbox.options[i].value;
        if (fbox.options[i].selected && fbox.options[i].value != "") {
          arrTbox[tLength] = fbox.options[i].text;
          tLength++;
        }
        else {
          arrFbox[fLength] = fbox.options[i].text;
          fLength++;
        }
      }
      arrFbox.sort();
      arrTbox.sort();
      fbox.length = 0;
      tbox.length = 0;
      var c;
      for(c = 0; c < arrFbox.length; c++) {
        var no = new Option();
        no.value = arrLookup[arrFbox[c]];
        no.text = arrFbox[c];
        fbox[c] = no;
      }
      for(c = 0; c < arrTbox.length; c++) {
        var no = new Option();
        no.value = arrLookup[arrTbox[c]];
        no.text = arrTbox[c];
        tbox[c] = no;
      }
    }
    </script>
    </head>
    <body>
    <form name="combo_box">
    <table>
    <tr><td>
    <select multiple size="10" name="list1">
    <option value="12">Alabama</option>
    <option value="54">Alaska</option>
    <option value="65">Arizona</option>
    <option value="45">Arkansas</option>
    <option value="2">California</option>
    <option value="6">Colorado</option>
    <option value="81">Connecticut</option>
    <option value="5">Delaware</option>
    <option value="23">District of Columbia</option>
    <option value="58">Florida</option>
    <option value="87">Georgia</option>
    <option value="98">Hawaii</option>
    <option value="53">Idaho</option>
    <option value="22">Illinois</option>
    <option value="28">Indiana</option>
    <option value="89">Iowa</option>
    <option value="71">Kansas</option>
    <option value="35">Kentucky</option>
    <option value="85">Louisiana</option>
    <option value="9">Maine</option>
    <option value="7">Maryland</option>
    <option value="77">Massachusetts</option>
    <option value="36">Michigan</option>
    <option value="87">Minnesota</option>
    <option value="66">Mississippi</option>
    <option value="34">Missouri</option>
    <option value="50">Montana</option>
    <option value="20">Nebraska</option>
    <option value="25">Nevada</option>
    <option value="32">New Hampshire</option>
    <option value="27">New Jersey</option>
    <option value="74">New Mexico</option>
    <option value="17">New York</option>
    <option value="3">North Carolina</option>
    <option value="13">North Dakota</option>
    <option value="4">Ohio</option>
    <option value="21">Oklahoma</option>
    <option value="12">Oregon</option>
    <option value="48">Pennsylvania</option>
    <option value="63">Rhode Island</option>
    <option value="82">South Carolina</option>
    <option value="14">South Dakota</option>
    <option value="72">Tennessee</option>
    <option value="49">Texas</option>
    <option value="47">Utah</option>
    <option value="92">Vermont</option>
    <option value="59">Virginia</option>
    <option value="52">Washington</option>
    <option value="41">West Virginia</option>
    <option value="46">Wisconsin</option>
    <option value="95">Wyoming</option>
    </select>
    </td>
    <td align="center" valign="middle">
    <input type="button" onClick="move(this.form.list2,this.form.list1)" value="<<">
    <input type="button" onClick="move(this.form.list1,this.form.list2)" value=">>">
    </td>
    <td>
    <select multiple size="10" name="list2">
    </select>
    </td>
    <td align="center" valign="middle">
    <input type="button" onClick="move(this.form.list3,this.form.list2)" value="<<">
    <input type="button" onClick="move(this.form.list2,this.form.list3)" value=">>">
    </td>
    <td>
    <select multiple size="10" name="list3">
    </select>
    </td>
    </tr></table>
    </form>
    <p><center>
    <font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
    by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
    </center><p>
    </body>
    </html>
    We help alot of people here. Sometimes they do expect us to do work for which they get paid... sometimes we do - sometimes we don't Sometimes it pisses us off - what can I say

  11. #11
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Vic beat me to the punch!

  12. #12
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what can I say
    ...just say: no.

  13. #13
    Non-Member leonte's Avatar
    Join Date
    Jul 2004
    Location
    Dubai
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    7stud - you posted 3 times completely offtopic
    1009 msgs of pure spam i`m sure

  14. #14
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awww, let's drop it

    leonte, did you try my suggestion?


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
  •