切换选择列表的项目 [英] Toggle items of a select list

查看:71
本文介绍了切换选择列表的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是填充选择列表的方式:

Here is how a fill select lists:

 $(document).ready(function () {
   $.ajax({
     url: "/JSON/GetSourceCurrencies/",
     type: "GET",
     success: function (result) {
     $('#SendCurrencyID').html('');               

     for (var k in result) {
     $('#SendCurrencyID').append('<option value="' + result[k].key + '">' + result[k].value + '</option>');
     $('#RecieveCurrencyID').append('<option value="' + result[k].key + '">' + result[k].value + '</option>');
     }
}
}); 





JSON数据:

[{key:1,value:EUR} ,{key:2,value:GBP},{key:3,value:USD}]



更改事件:



JSON Data :
[{"key":1,"value":"EUR"},{"key":2,"value":"GBP"},{"key":3,"value":"USD"}]

Change Event:

$("select[id$='CurrencyID']").change(function () {
   var selectedID = $(this).val();
   $(this).next().find("option[value='" + selectedID + "']").remove();
});







HTML:




HTML:

<select id="SendCurrencyID"></select>
<select id="RecieveCurrencyID"></select>





当我从其中一个选择列表中选择货币时,需要删除其他选择列表中的所选货币。



When I select a currency from one of the select lists, the selected currency in other select list is needed to be removed.

推荐答案

(< span class =code-sdkkeyword> document )。ready( function (){
(document).ready(function () {


.ajax( {
url: / JSON / GetSourceCurrencies /,
类型: 获取
成功: function (结果){
.ajax({ url: "/JSON/GetSourceCurrencies/", type: "GET", success: function (result) {


' #SendCurrencyID')。html(' ');

for var k 结果中){
('#SendCurrencyID').html(''); for (var k in result) {


这篇关于切换选择列表的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆