Select
清空原选择项:
document.getElementById("select_zjlx")[1].selected = false;
document.getElementById("select_zjlx")[2].selected = false;
document.getElementById("select_zjlx")[3].selected = false;
document.getElementById("select_zjlx")[4].selected = false;
设置新选择项
document.getElementById("select_zjlx")[0].selected = true;
document.getElementById("sfzh").value = "";
document.getElementById("xm").value = "";
附注:html中<select>标签用法解析http://www.169it.com/article/381029070941313083.html
使用实例:
一、html
1、
<select id="select_zjlx" class="selectbox1" onchange="change(this)">
<option value="R" selected="selected">中国大陆居民</option>
<option value="H" >香港居民</option>
<option value="M" >澳门居民</option>
<option value="T" >台湾居民</option>
<option value="F" >外国人</option>
</select>
2、
<div class="china" >
<div class="tj_cell">
<div class="tj_cell_ft" style="width:80px">身份证号</div>
<div class="tj_cell_primary">
<input id="sfzh" class="tj_input" type="text" maxlength="18" placeholder="请输入身份证号" />
</div>
</div>
<div class="tj_cell">
<div class="tj_cell_ft" style="width:80px">姓 名</div>
<div class="tj_cell_primary">
<input id="xm" class="tj_input" type="text" maxlength="9" placeholder="请输入姓名(简体)" />
</div>
</div>
</div>
<div class="foreign" style="display:none;">
<div class="tj_cell">
<div class="tj_cell_ft" style="width:80px">国籍地区</div>
<div class="tj_cell_primary">
<select id="select_gjdq" class="selectbox1" onchange="change(this)">
@{
System.Data.DataTable dt_Source = ViewBag.dt_Source;
if (dt_Source.Rows.Count == 0)
{
}
else
{
foreach (System.Data.DataRow row in dt_Source.Rows)
{
<option value=@row["DM"]>@row["MC"]</option>
}
}
}
</select>
</div>
</div>
<div class="tj_cell">
<div class="tj_cell_ft" style="width:80px">证件种类</div>
<div class="tj_cell_primary">
<select id="select_zjzl" class="selectbox1" onchange="">
<option value="14" selected="selected">普通护照</option>
<option value="13">因公普通护照</option>
<option value="11">公务护照</option>
<option value="12">外交护照</option>
</select>
</div>
</div>
<div class="tj_cell">
<div class="tj_cell_ft" style="width:80px">证件号码</div>
<div class="tj_cell_primary">
<input id="zjhm" class="tj_input" type="text" maxlength="18" placeholder="请输入证件号码" />
</div>
</div>
二、script
1、
function change(o) {
var rylb = o.value;
var sfzh = document.getElementById("sfzh");
switch (rylb) {
case "R":
chinashow();
foreignhide();
sfzh.placeholder = "请输入身份证号";
break;
case "H":
chinashow();
foreignhide();
sfzh.placeholder = "请输入香港身份证号";
break;
case "M":
chinashow();
foreignhide();
sfzh.placeholder = "请输入澳门身份证号";
break;
case "T":
chinashow();
foreignhide();
sfzh.placeholder = "请输入台湾身份证号";
break;
case "F":
chinahide();
foreignshow();
break;
default:
}
}
2、
function SearchProgress() {
// 查询结果,隐藏+置空
$("#lbRsultValue").hide();
$("#lrv").html('');
var sfzh = $("#sfzh").val();
var xm = $("#xm").val();
var rylb = $("#select_zjlx").val();
var gjdq = $("#select_gjdq").val();
var zjzl = $("#select_zjzl").val();
var zjhm = $("#zjhm").val();
if (rylb != "F") {
// 验证身份证号是否存在
if (!sfzhvalidate("sfzh")) {
return false;
}
// 姓名是否填写
if (xm == null) {
alert("请填写姓名");
return;
}
}
if (rylb == "F") {
// 外国人
$("#zjhm").val(zjhm.toUpperCase());
zjhm = zjhm.toUpperCase();
AjaxSubmit('@Url.Action("ForeignJDCX", "YWCX")', {rylb:rylb, gjdq:gjdq, zjzl:zjzl, zjhm:zjhm }, null, function (data) {
if (data.Result && data.Data != null) {
RestoreState();
location.href = "@Url.Action("WJSLBHCXJG", "YWCX")?rylb=" + rylb + "&gjdq=" + gjdq + "&zjzl=" + zjzl + "&zjhm=" + zjhm + "&type=2";
}
else {
alert("没有获取相关数据!");
location.href = "";
}
})
} else {
//中国人
AjaxSubmit('@Url.Action("ChinaJDCX", "YWCX")', { rylb: rylb, sfzh: sfzh, xm: xm }, null, function (data) {
if (data.Result && data.Data != null) {
RestoreState();
location.href = "@Url.Action("WJSLBHCXJG", "YWCX")?rylb=" + rylb + "&sfzh=" + sfzh + "&xm=" + xm + "&type=0";
}
else {
$("#lrv").html("没有获取相关数据!");
location.href = "";
}
})
}
}
// 记录恢复初始状态------返回时会恢复到初始的状态
function RestoreState() {
document.getElementById("select_zjlx")[1].selected = false;
document.getElementById("select_zjlx")[2].selected = false;
document.getElementById("select_zjlx")[3].selected = false;
document.getElementById("select_zjlx")[4].selected = false;
document.getElementById("select_zjlx")[0].selected = true;
document.getElementById("sfzh").value = "";
document.getElementById("xm").value = "";
}