嗨,我在这里有新的PHP,所以我需要一个帮助人 我有一个输入和2个选择选项我想要----如果输入为空,则两个选择也是空的如果输入有一些值而不是第一个选择值应该是'打开'并且第二个选择值应该是'形式分发'像这样,这里两个选择都工作正常,但没有输入字段跟随任何帮助将gratfull谢谢你
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function configureDropDownLists(ddl1,ddl2) {
var Open = new Array('Form Distributed');
var Completed = new Array('Ready for billing', 'Completed');
var Pending = new Array('With CS', 'With O&M (Estimate)', 'With Delegate','With Executive Engineer','With Consumer (Payment)','With O&M (Connection)');
var Rejected = new Array('Rejected: By CS', 'Rejected: By O&M', 'Rejected: By Delegate','Rejected: By EE','Rejected: Demand Expired','Rejected: By O&M');
switch (ddl1.value) {
case 'Open':
document.getElementById(ddl2).options.length = 0;
for (i = 0; i < Open.length; i++) {
createOption(document.getElementById(ddl2), Open[i], Open[i]);
}
break;
case 'Completed':
document.getElementById(ddl2).options.length = 0;
for (i = 0; i < Completed.length; i++) {
createOption(document.getElementById(ddl2), Completed[i], Completed[i]);
}
break;
case 'Pending':
document.getElementById(ddl2).options.length = 0;
for (i = 0; i < Pending.length; i++) {
createOption(document.getElementById(ddl2), Pending[i], Pending[i]);
}
break;
case 'Rejected':
document.getElementById(ddl2).options.length = 0;
for (i = 0; i < Rejected.length; i++) {
createOption(document.getElementById(ddl2), Rejected[i], Rejected[i]);
}
break;
default:
document.getElementById(ddl2).options.length = 0;
break;
}
}
function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}
</script>
</head>
<input type="text" name="date" id="datepicker">
<select id="ddl" onChange="configureDropDownLists(this,'ddl2')">
<option value="0" ></option>
<option value="Open">Open</option>
<option value="Completed">Completed</option>
<option value="Pending">Pending</option>
<option value="Rejected">Rejected</option>
</select>
<select id="ddl2">
</select>
</body>
</html>
答案 0 :(得分:0)
(文档)$。就绪(函数(){
changeInput();
$("#datepicker").change(function(){
changeInput();
});
});
var options = ['Open','Completed','Pending','Rejected']; 功能改变输入(){
var input = $("#datepicker").val();
var ddl = document.getElementById("ddl");
ddl.options.length = 0;
document.getElementById("ddl2").options.length = 0;
if(input==""){
}else{
$.each(optios,function(){
var opt = document.createElement('option');
opt.value = this;
opt.text = this;
ddl.options.add(opt);
});
$("#ddl").val("Open");
configureDropDownLists(ddl,'ddl2');
}
}