9. Option conversion in the two drop-down lists

Source: Internet
Author: User

 

Realtimehistory_lkj_alloption -- list on the left

Realtimehistory_lkj_selectoption -- list on the right

// Shift right
$ (". Realtimehistory_lkj_rightmove"). Unbind ("click"). Click (function (){
$. Each ($ (". realtimehistory_lkj_alloption option: Selected"), function (I, item ){
$ (". Realtimehistory_lkj_alloption option [value = '" + $ (item). Val () + "']"). Remove ();
$ (". Realtimehistory_lkj_selectoption "). append ("<option value = '" + $ (item ). val () + "'>" + $ (item ). text () + "</option> ");
});

});

// Move left
$ (". Realtimehistory_lkj_leftmove"). Unbind ("click"). Click (function (){
$. Each ($ (". realtimehistory_lkj_selectoption option: Selected"), function (I, item ){
$ (". Realtimehistory_lkj_selectoption option [value = '" + $ (item). Val () + "']"). Remove ();
$ (". Realtimehistory_lkj_alloption "). append ("<option value = '" + $ (item ). val () + "'>" + $ (item ). text () + "</option> ");
});
});

// Move all right
$ (". Realtimehistory_lkj_allrightmove"). Unbind ("click"). Click (function (){
$. Each ($ (". realtimehistory_lkj_alloption option"), function (I, item ){
$ (". Realtimehistory_lkj_alloption option [value = '" + $ (item). Val () + "']"). Remove ();
$ (". Realtimehistory_lkj_selectoption "). append ("<option value = '" + $ (item ). val () + "'>" + $ (item ). text () + "</option> ");
});
});

// Move all to the left
$ (". Realtimehistory_lkj_allleftmove"). Unbind ("click"). Click (function (){
$. Each ($ (". realtimehistory_lkj_selectoption option"), function (I, item ){
$ (". Realtimehistory_lkj_selectoption option [value = '" + $ (item). Val () + "']"). Remove ();
$ (". Realtimehistory_lkj_alloption "). append ("<option value = '" + $ (item ). val () + "'>" + $ (item ). text () + "</option> ");
});
});

// Move up
$ (". Realtimehistory_lkj_upmove"). Unbind ("click"). Click (function (){
If ($ (". realtimehistory_lkj_selectoption option: Selected"). length> 0 ){
VaR selectindex = $ (". realtimehistory_lkj_selectoption"). Get (0). selectedindex;

If (selectindex> 0 ){
$ ('. Realtimehistory_lkj_selectoption option: selected'). insertbefore ($ ('. realtimehistory_lkj_selectoption option: selected'). Prev ('option '));
} Else {
Alert ("This is the first item. ");
}
} Else {
Alert ("select one... ");
}
});

// Move down
$ (". Realtimehistory_lkj_downmove"). Unbind ("click"). Click (function (){
If ($ (". realtimehistory_lkj_selectoption option: Selected"). length> 0 ){
VaR selectlength = $ (". realtimehistory_lkj_selectoption option"). length;
VaR selectindex = $ (". realtimehistory_lkj_selectoption"). Get (0). selectedindex;
If (selectindex <selectLength-1 ){
$ ('. Realtimehistory_lkj_selectoption option: selected'). insertafter ($ ('. realtimehistory_lkj_selectoption option: selected'). Next ('option '));
} Else {
Alert ("this is the last item. ");
}
} Else {
Alert ("select one... ");
}
});

9. Option conversion in the two drop-down lists

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.