I have hands on in handling two listboxes, one in the left and one in the right.
I have a requirement where I have 4 listboxes in the left and if I select the items from the listboxes and press the right >>, it moves to the final listbox.
Now I find it difficult to move the values from the final listbox to respective left listboxes when I press <<.
Please someone guide on this.This message has been edited. Last edited by: Ramya,
WebFocus 7702 HTML
June 17, 2016, 04:13 AM
Ruchika Gusain
I have implemented the same with the two listbox in the left(leftlistbox1, leftlistbox2) and one in the right(finallistbox).
What I did, is just capture the id of selected value listbox(the one whose in the left) and then pass that value to the final listbox(in the right).
Steps: 1) Select the value from the left listbox and capture the id of that listbox at onchange event listbox_name=$(this).attr('id');
2) On clicking >> button just append that selected listbox id to the value with '~' separated and move it to the final listbox
var newOption = new Option(); // Create a new instance of ListItem newOption.text = Source.options[Source.options.selectedIndex].text; newOption.value = Source.options[Source.options.selectedIndex].value+'~'+listbox_name;
3) Now select the value from the final listbox(in the right) and at onchange event, separate the value and id with '~' separated
var e = document.getElementById('finallistbox'); var dflSel = e.options[e.selectedIndex].value; var value=dflSel.indexOf('~'); listbox_name=dflSel.substring(value+1, dflSel.length);
4) On clicking << button just check into which listbox the value should move
if(listbox_name=='leftlistbox1') MoveItem('finallistbox', 'leftlistbox1'); else if (listbox_name=='leftlistbox2') MoveItem('finallistbox', 'leftlistbox2');
You can implement the same with 4 list boxes in the left. I also have the implemented HTML, if you require, just share me your personal id.
WebFOCUS 7.7 , 8.0, 8.1 Windows 7 Excel, PDF, HTML
June 17, 2016, 05:58 AM
Ramya
Dear Ruchica,
Thanks so much. Its really helpful.Would feel better if you can share me the HTML also. My personal ID is ramyagopi88@gmail.com
Thanks, Ramya
WebFocus 7702 HTML
June 21, 2016, 03:33 AM
Ramya
Hi Ruchica,
The code you have sent me worked good.
I have dropped you an email saying its not working fine for 3 listboxes and this morning I have done some modifications and its working fine.
Now I am into one more challenge.
Moving values from listbox1 to target, listbox2 to target and listbox3 to target is fine.
Now the challenge is, selecting values from all the three listboxes and making it move to target in a single click.
If anyone has any idea, please come up with.
WebFocus 7702 HTML
June 22, 2016, 06:25 AM
Ramya
Hi All,
Finally got them working.
I have introduced the array concept and kept appending the array with values I selected from multiple listboxes and finally populated the target listbox with array values.
Thanks all for your help.
WebFocus 7702 HTML
June 23, 2016, 04:06 PM
Ram Prasad E
Edit your first post to add the text "Solved" to subject line.