如何用脚本判断DropDownList的哪一项被选中 这是 Server 端代码,你需要客户端 JS 验证还是 Server 端验证? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 为DropDownList的每个选项各指定一个TextBox,为TextBox指定合适的验证控件,剩下要做的就是用javascript控制显示... 在TextBox 内输入内容,这是一个搜索栏,DropDownList控制按照Nurse_ID或者Nurse_Name 的选择方式查询,因为类行不同所以要用不同的验证表达式对输入栏进行验证 呵呵,HIS 系统,都是 Nurse简单写一个,写完去吃饭! checkAll(); LZ 自己完成吧,吃饭去喽! <body> <input type="button" id="btnSubmint" value="Submit" /> <select id="NurseInfoSearchDropDownList"> <option value="all" selected>default</option> <option value="nurse_id">nurse_id</option> <option value="Nurse_Name">Nurse_Name</option> <option value="Age">Age</option> <option value="ManagerName">ManagerName</option> </select><br /> nurse_id<input type="text" id="nurse_id" /><br /> Nurse_Name<input type="text" id="Nurse_Name" /><br /> Age<input type="text" id="Age" /><br /> ManagerName<input type="text" id="ManagerName" /><br /><script type="text/javascript"><!--document.all.btnSubmint.onclick = function(){ var strSelectedValue = document.all.NurseInfoSearchDropDownList.value; switch (strSelectedValue) { case "all": return checkAll(); break; default: return checkSingle(strSelectedValue); break; }};function checkSingle(strId){ var oText = document.getElementById(strId); if (oText.value == "") { alert("Please input something for "+strId+"!"); return false; }}//--></script> </body> 哈,饭后散步回来,心情不错,重新整理了一下代码,加点儿些色彩!L@_@K <body> <table> <tr> <td>Search Type</td> <td> <select id="NurseInfoSearchDropDownList"> <option value="all" selected>default</option> <option value="nurse_id">nurse_id</option> <option value="Nurse_Name">Nurse_Name</option> <option value="Age">Age</option> <option value="ManagerName">ManagerName</option> </select> </td> </tr> <tr> <td>nurse_id</td> <td><input type="text" id="nurse_id" /></td> </tr> <tr> <td>Nurse_Name</td> <td><input type="text" id="Nurse_Name" /></td> </tr> <tr> <td>Age</td> <td><input type="text" id="Age" /></td> </tr> <tr> <td>ManagerName</td> <td><input type="text" id="ManagerName" /></td> </tr> <tr> <td></td> <td align="right"><input type="button" id="btnSubmint" value="Submit" /></td> </tr> </table><script type="text/javascript"><!--document.all.btnSubmint.onclick = function(){ var strSelectedValue = document.getElementById("NurseInfoSearchDropDownList").value; switch (strSelectedValue) { case "all": return checkAll(); break; default: return checkSingle(strSelectedValue); break; }};function checkAll(){ var oSelect = document.getElementById("NurseInfoSearchDropDownList"); var strMessag = ""; var oOption, oInput; for (var i=1; i<oSelect.options.length; i++) { oOption = oSelect.options[i]; oInput = document.getElementById(oOption.value); if (oInput && oInput.value == "") { oInput.style.backgroundColor = "#ffff00"; oInput.onfocus = function () { this.style.backgroundColor = "#ffffff"; }; strMessag += "Please input something for "+oOption.text+"!\n"; } } if (strMessag != "") { alert(strMessag); return false; } }function checkSingle(strId){ var oText = document.getElementById(strId); if (oText.value == "") { oText.style.backgroundColor = "#ffff00"; oText.onfocus = function () { this.style.backgroundColor = "#ffffff"; }; alert("Please input something for "+strId+"!"); return false; }}//--></script> </body> 希望大家给推荐本书 js xmlhttp post传参失败,求解 |zyciis| 求一个日期输入的自动完成js ,非日期控件 谢谢 firefox下事件函数得不到event对象。 問本內容改變是能得到原來的值嗎. body 滚动条 可有这种东西? Extjs如何一键展开tree,数据量有几千行 <input type="text">里的值发生变化有 on什么 之类的事件可以监听吗? 怎样去掉超连接下的下划线 框架中有好几个页面组成,父窗体如何把获取到的参数传递给各个子框架内的页面? 倒计时关闭提示框
<input type="button" id="btnSubmint" value="Submit" />
<select id="NurseInfoSearchDropDownList">
<option value="all" selected>default</option>
<option value="nurse_id">nurse_id</option>
<option value="Nurse_Name">Nurse_Name</option>
<option value="Age">Age</option>
<option value="ManagerName">ManagerName</option>
</select><br />
nurse_id<input type="text" id="nurse_id" /><br />
Nurse_Name<input type="text" id="Nurse_Name" /><br />
Age<input type="text" id="Age" /><br />
ManagerName<input type="text" id="ManagerName" /><br />
<script type="text/javascript">
<!--
document.all.btnSubmint.onclick = function()
{
var strSelectedValue = document.all.NurseInfoSearchDropDownList.value;
switch (strSelectedValue)
{
case "all":
return checkAll();
break;
default:
return checkSingle(strSelectedValue);
break;
}
};function checkSingle(strId)
{
var oText = document.getElementById(strId);
if (oText.value == "")
{
alert("Please input something for "+strId+"!");
return false;
}
}
//-->
</script>
</body>
<body>
<table>
<tr>
<td>Search Type</td>
<td>
<select id="NurseInfoSearchDropDownList">
<option value="all" selected>default</option>
<option value="nurse_id">nurse_id</option>
<option value="Nurse_Name">Nurse_Name</option>
<option value="Age">Age</option>
<option value="ManagerName">ManagerName</option>
</select>
</td>
</tr>
<tr>
<td>nurse_id</td>
<td><input type="text" id="nurse_id" /></td>
</tr>
<tr>
<td>Nurse_Name</td>
<td><input type="text" id="Nurse_Name" /></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" id="Age" /></td>
</tr>
<tr>
<td>ManagerName</td>
<td><input type="text" id="ManagerName" /></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="button" id="btnSubmint" value="Submit" /></td>
</tr>
</table>
<script type="text/javascript">
<!--
document.all.btnSubmint.onclick = function()
{
var strSelectedValue = document.getElementById("NurseInfoSearchDropDownList").value;
switch (strSelectedValue)
{
case "all":
return checkAll();
break;
default:
return checkSingle(strSelectedValue);
break;
}
};function checkAll()
{
var oSelect = document.getElementById("NurseInfoSearchDropDownList");
var strMessag = "";
var oOption, oInput;
for (var i=1; i<oSelect.options.length; i++)
{
oOption = oSelect.options[i];
oInput = document.getElementById(oOption.value);
if (oInput && oInput.value == "")
{
oInput.style.backgroundColor = "#ffff00";
oInput.onfocus = function ()
{
this.style.backgroundColor = "#ffffff";
};
strMessag += "Please input something for "+oOption.text+"!\n";
}
} if (strMessag != "")
{
alert(strMessag);
return false;
}
}
function checkSingle(strId)
{
var oText = document.getElementById(strId);
if (oText.value == "")
{
oText.style.backgroundColor = "#ffff00";
oText.onfocus = function ()
{
this.style.backgroundColor = "#ffffff";
};
alert("Please input something for "+strId+"!");
return false;
}
}
//-->
</script>
</body>