2014-01-20 92 views
0

我想要做的是上传CSV文件,然后计算文件的列数,然后根据其内容安排列。如何在选择后从选择框中删除值

例如:CSV文件有3列,用户现在可以确定列的内容,以便它可以正确上载到数据库。

如何使用选择选项来填充输入框,在用户从选择框中选择将被禁用的值之后。

enter image description here

选择框将包含特定的值。

enter image description here

选择后的价值现在是从以前的选择框禁用或删除,直到选中。

enter image description here

类似Jquery Tag's Multi Selectorhttp://harvesthq.github.io/chosen/#multiple-select

,但它会被分发到CSV文件中创建的每个行。

回答

1

试试这个:http://jsfiddle.net/rM88C/2/

应允许您添加的“jQuery的选择了”下拉菜单中的不确定量,并有任何选择的值“已禁用”在所有的下拉列表中使用相同的类名。我提供了多选版本,但为了您的目的将其转换为单一选择版本应该是微不足道的。

Javascript代码下面提供的,但检查出小提琴第一

// get selects for later use 
var selects = $('.myChosen'); 

// whenever the selection changes, either disable or enable the 
// option in the other selects 
selects.chosen().change(function() { 
    var selected = []; 

    // add all selected options to the array 
    selects.find("option").each(function() { 
     if (this.selected) { 
      selected[this.value] = this; 
     } 
    }) 

    // disable or enable options 
    .each(function() { 

     // if the current option is already selected in another select disable it. 
     // otherwise, enable it. 
     this.disabled = selected[this.value] && selected[this.value] !== this; 
    }); 

    // trigger the change event in the other "chosen" selects 
    selects.trigger("chosen:updated"); 
});