我有以下的Java脚本代码......如何检查选择框的组是否入围与否
var dataString = 'CategoryId='+categoryid+"&FormatId="+formatid;
$.ajax({
type:"Post",
url:"MyServlet",
datatype:"json",
data : dataString,
success: function(data){
var type1= data.a;
var type2 = data.b;
var type3 = data.c;
var type4 = data.d;
var type5 = data.e;
var type6 = data.f;
if(type1){
$('#type1id').append("<option value=0>SelectOne</option>");
$.each(type1, function(i, value){
$('#type1id').append("<option value='"+this.Id+"'>"+this.DisplayName+"</option>");
});
$('#set1').show();
}
else{
$('#set1').hide();
}
if(type2){
$('#type2id').append("<option value=0>SelectOne</option>");
$.each(type2, function(i, value){
$('#type1id').append("<option value='"+this.Id+"'>"+this.DisplayName+"</option>");
});
$('#set2').show();
}
else{
$('#set2').hide();
}
if(type3){
$('#type3id').append("<option value=0>SelectOne</option>");
$.each(type3, function(i, value){
$('#type3id').append("<option value='"+this.Id+"'>"+this.DisplayName+"</option>");
});
$('#set3').show();
}
else{
$('#set3').hide();
}
// etc...
// etc...
// till type6
}
});
我有以下的html代码......
<div id="section-2" class="section-content">
<fieldset id="set1">
<label for="type1id">Type 1</label>
<select id="type1id"> </select>
</fieldset>
<fieldset id="set2">
<label for="type2id">Type 2</label>
<select id="type2id"> </select>
</fieldset>
<fieldset id="set3">
<label for="type3id">Type 3</label>
<select id="type3id"> </select>
</fieldset>
</div>
<button disabled="disabled" type="button" id="section2-next">
Next
</button>
我通过获取json响应动态地使用$ .ajax()函数动态填充所有选择框.. 显示的选择框数量取决于json数据,例如,如果json返回1数组,那么我只显示1个选择框,如果json返回2数组我显示2选择框等....如何检查是否所有显示的选择框选择,然后然后只启用下一步按钮?
那么,如何检查每一个选择框已加载的东西?或者如果只有可用选项有选项选项? – tymeJV
选择框是否有空白值?如果没有,他们会一直有选择的东西。根据你发布的内容来回答真的不可能。 – meagar
我编辑了代码..... –