/// <summary>
/// 电话查询页面
/// </summary>
/// <returns></returns>
public ActionResult PhoneSearch(string sql)
{
phoneList=从数据库查询数据;
ViewBag.phoneList = phoneList;
return View();
}
<table border="1" cellspacing="0" cellpadding="0" class="toLang" id="phoneTable">
<tr>
<th>序号</th>
<th>公司</th>
<th>部门</th>
<th>小组</th>
<th>姓名</th>
<th>职位</th>
<th>电话</th>
</tr>
<tbody id="todeListTBODY">
@if (ViewBag.phoneList != null)
{
foreach (var item in ViewBag.phoneList)
{
number = number + 1;
<tr>
<td>@number</td>
<td>@item.Conpany</td>
<td>@item.Department</td>
<td>@item.Team</td>
<td>@item.Name</td>
<td>@item.Position</td>
<td>@item.PhoneNumber</td>
</tr>
}
}
</tbody>
</table>
<div style="display:block;float:left; width:100%; ">
公司:
<select class="InputTestStyle" id="company" onclick="initDeptSelect()">
<option>==请选择公司==</option>
</select>
部门:
<select class="InputTestStyle" id="department" onclick="initGroupSelect()">
<option>==请选择公司==</option>
</select>
小组:
<select class="InputTestStyle" id="group" onclick="QueryPhoneNum()">
<option>==请选择公司==</option>
</select>
</div>
//打开页面的时候执行
window.onunload = initCompanySelect();
//初始化“公司”下拉框
function initCompanySelect()
{
$.ajax({
type: 'POST',
url: '/Home/GetCompantListForPhone',
dataType: 'json',
data: { },
success: function (data) {
//1.清空这个下拉框的数据
// $('#company option').remove();//也能成功实现
$('#company').empty();
$("#company").append($('<option>' + '==请选择公司==' + '</option>'));
//2.将返回值动态加载进下拉框,动态生成标签。
for (i = 0; i < data.length;i++)
{
$("#company").append($('<option >' + data[i].Conpany + '</option>'));
}
},
error: function (XMLHttpRequest, textStatus, errorThown) {
alert("操作失败!");
}
})
}
/// <summary>
/// 获取电话查询公司下拉数据
/// </summary>
/// <returns></returns>
[HttpPost]
public JsonResult GetCompantListForPhone()
{
compantList = 从数据库获取这个下拉框数据的集合;
return Json(compantList);
}
//根据条件查询电话
function QueryPhoneNum()
{
if ($('#group').val() == '==请选择小组==')
{
return;
}
number = 0;
$.ajax({
type: 'POST',
url: '/Home/PhoneSearchSubmit',
dataType: 'json',
data: {
company:$('#company').val(),
dept: $('#department').val(),
group: $('#group').val()
},
success: function (phoneList) {
//1.清空这个表格的数据
$('#todeListTBODY tr').remove();
//2.将返回值动态加载进表格。
$.each(phoneList, function (index, element) {
number = number + 1;
$('#todeListTBODY').prepend(function (i) {
return "<tr>" +
"<td>" +number +
"<td>" + element.Conpany +
"<td>" + element.Department +
"<td>" + element.Team +
"<td>" + element.Name +
"<td>" + element.Position +
"<td>" + element.PhoneNumber +
"</tr>";
})
})
},
error: function (XMLHttpRequest, textStatus, errorThown) {
alert("操作失败!");
}
})
}
/// <summary>
/// 电话查询
/// </summary>
/// <returns></returns>
[HttpPost]
public JsonResult PhoneSearchSubmit(string company, string dept, string group)
{
phoneList = 根据条件查询数据;
return Json(phoneList);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有