+ Reply to Thread
Results 1 to 12 of 12

Thread: move data from one listbox to another list box
      
   

  1. #1
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Smile move data from one listbox to another list box

    Hi,


    How to move data from one listbox to another list box in php?
    any one can give an example ........



    Thanks,
    Sreenu.G

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: move data from one listbox to another list box

    Can you please provide an example of what you need to do ?
    If made in php it will probably require refreshing the page, if made through Javascript or Ajax it may be done on real time (without refreshing the page).
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  3. #3
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Default Re: move data from one listbox to another list box

    Thanks for helping..

    my code is

    <td style="width: 100px;"><label for="city1">City(s)</label>
    <br />

    <?php
    $city1 = $_POST['CityId1'];
    if($country)
    echo $this->formSelect('CityId1', $city1, array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());// here i will get all the cites those will be in first list box
    else
    echo $this->formSelect('CityId1', 'Hyderabad', array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());
    ?>

    </td>

    <td style="width: 30px;">
    <input style="width: 120px;" type="button" id="toright" name="toright" value=">>" onclick=" " /><br />
    <input style="width: 120px;" type="button" name="toleft" name="toleft" value= "<<" onclick=" " />
    </td>

    <td>
    <label for="city2">Selected City(s)</label>
    <select id="CityId2" name="CityId2" multiple="multiple" style="height: 100px; width: 100px;">
    //when will click on >> button selected city of first list box data must display in the second list box
    </select>
    </td>



    this is phtml page iam using PHP ...............

  4. #4
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: move data from one listbox to another list box

    This can NOT be the entire script. There must be some backend script and functions that perform the desired actions. Without them i don't think anyone can help you.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  5. #5
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Smile Re: move data from one listbox to another list box

    my code is

    <td style="width: 100px;"><label for="city1">City(s)</label>
    <br />

    <?php
    $city1 = $_POST['CityId1'];
    if($country)
    echo $this->formSelect('CityId1', $city1, array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());// here i will get all the cites those will be in first list box
    else
    echo $this->formSelect('CityId1', 'Hyderabad', array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());
    ?>

    </td>

    <td style="width: 30px;">
    <input style="width: 120px;" type="button" id="toright" name="toright" value=">>" onclick="moveoutid()" /><br />
    <input style="width: 120px;" type="button" name="toleft" name="toleft" value= "<<" onclick="moveinid()" />
    </td>

    <td>
    <label for="city2">Selected City(s)</label>
    <select id="CityId2[]" name="CityId2[]" multiple="multiple" style="height: 100px; width: 100px;">
    //when will click on >> button selected city of first list box data must display in the second list box
    </select>
    </td>

    <input type="submit" id="save" name="save" value="Save" />


    by using javascript when ever i press >> button i can take out the value from first list box and i can place inside second list box , iam doing same think for << button also

    my javascript code is :

    function moveoutid()
    {
    var selcity1 = document.getElementById('CityId1');;
    var len = selcity1.length;
    var selcity2 = document.getElementById('CityId2');
    for(var j=0; j<len; j++)
    {
    if(selcity1[j].selected)
    {
    var tmp = selcity1.options[j].text;
    var tmp1 = selcity1.options[j].value;
    selcity1.remove(j);
    j--;
    var y=document.createElement('option');
    y.text=tmp;
    try
    {selcity2.add(y,null);
    }
    catch(ex)
    {
    selcity2.add(y);
    }
    }
    }
    }


    function moveinid()
    {
    var selcity1 = document.getElementById('CityId1');
    var selcity2 = document.getElementById('CityId2');
    var len = selcity2.length;
    for(var j=0; j<len; j++)
    {
    if(selcity2[j].selected)
    {
    var tmp = selcity2.options[j].text;
    var tmp1 = selcity2.options[j].value;
    selcity2.remove(j);
    j--;
    var y=document.createElement('option');
    y.text=tmp;
    try
    {
    selcity1.add(y,null);}
    catch(ex){
    selcity1.add(y);
    }

    }
    }
    }
    </script>


    MY QUESTION IS :
    when ever i press Save button it goes to the validation part in server side,
    by using $advCity2 = $_POST['advCity2[]']; i want to take the all the second list box values and save inside the database . but all the values are not coming ? what shall i do?

    any body please help me urgent....

  6. #6
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Question how to pass multiple listboxes values to server side?

    MY QUESTION IS :
    i have 2 multiple list boxes , first list box contains 10 cityes , between the listboxes i have two buttons >> and << , when i select >> button i need to take out the value from listbox1 and keep inside the listbox2....

    when ever i press Save button it need to take all the adCity2 values and save inside the database . but iam unable to get adCity2 listbox(2nd listbox )values ... how can i get adCity2 values from browser to serverside to store inside db?


    any body please help me urgent....


    <td style="width: 100px;"><label for="city1">City(s)</label>
    <br />

    <?php
    $city1 = $_POST['CityId1'];
    if($country)
    echo $this->formSelect('CityId1', $city1, array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());// here i will get all the cites those will be in first list box
    else
    echo $this->formSelect('CityId1', 'Hyderabad', array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());
    ?>

    </td>

    <td style="width: 30px;">
    <input style="width: 120px;" type="button" id="toright" name="toright" value=">>" onclick="moveoutid()" /><br />
    <input style="width: 120px;" type="button" name="toleft" name="toleft" value= "<<" onclick="moveinid()" />
    </td>

    <td>
    <label for="city2">Selected City(s)</label>
    <select id="CityId2[]" name="CityId2[]" multiple="multiple" style="height: 100px; width: 100px;">
    //when will click on >> button selected city of first list box data must display in the second list box
    </select>
    </td>

    <input type="submit" id="save" name="save" value="Save" />



    my javascript code is :

    function moveoutid()
    {
    var selcity1 = document.getElementById('CityId1');;
    var len = selcity1.length;
    var selcity2 = document.getElementById('CityId2');
    for(var j=0; j<len; j++)
    {
    if(selcity1[j].selected)
    {
    var tmp = selcity1.options[j].text;
    var tmp1 = selcity1.options[j].value;
    selcity1.remove(j);
    j--;
    var y=document.createElement('option');
    y.text=tmp;
    try
    {selcity2.add(y,null);
    }
    catch(ex)
    {
    selcity2.add(y);
    }
    }
    }
    }


    function moveinid()
    {
    var selcity1 = document.getElementById('CityId1');
    var selcity2 = document.getElementById('CityId2');
    var len = selcity2.length;
    for(var j=0; j<len; j++)
    {
    if(selcity2[j].selected)
    {
    var tmp = selcity2.options[j].text;
    var tmp1 = selcity2.options[j].value;
    selcity2.remove(j);
    j--;
    var y=document.createElement('option');
    y.text=tmp;
    try
    {
    selcity1.add(y,null);}
    catch(ex){
    selcity1.add(y);
    }

    }
    }
    }
    </script>

  7. #7
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: move data from one listbox to another list box

    http://www.mattkruse.com/javascript/...fer/index.html

    Once you have finished the Transfer Option, use ABVFP to process your form, so it will automatically store the values in the database.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  8. #8
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Default Re: move data from one listbox to another list box

    How can i get OptioTransfer.js file ?

  9. #9
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: move data from one listbox to another list box

    Click on "Source" in the link i provided.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  10. #10
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Default Re: move data from one listbox to another list box

    iam getting errors like

    OptionTransfer is not defined

    and

    this.originalLeftValues has no properties

  11. #11
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: move data from one listbox to another list box

    Well, i can't help you with setting up correctly the Javascript. This requires quite a lot of time. I can only suggest that you read carefully the instructions provided by the author.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  12. #12
    callsreenu is offline Corporal
    Join Date
    Nov 2008
    Posts
    10

    Default Re: move data from one listbox to another list box

    Thanks i got it...........

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49