我正在使用jLinq来查询Array
Objects
的{{1}}
但我想动态查询获取Selects
这是我的例子:
<select id="firt"><option>Select 1</option></select>
<select id="last"><option>Select 2</option></select>
<select id="phone"><option>Select 3</option></select>
myNewArray = jlinq.from( array ).sort( "date" )
.equals( "first", $( "#first" ).find( "option:selected" )
.equals( "last", $( "#last" ).find( "option:selected" )
.equals( "phone", $( "#phone" ).find( "option:selected" )
.group( "state" );
但我想要这样的事情:
myNewArray = jlinq.from( array ).sort( "date" )
//for each selected option
.group( "state" );
答案 0 :(得分:0)
我找到了解决方案:
function makeQuery() {
var query = 'jlinq.from( array ).sort( "date" )';
$('select').each(function(index) {
query += '.equals( "' + this.id + '", "' + this.value + '")';
});
query += '.group( "state" );'
$('#query').html(query);
//myNewArray = eval(query);
}