HTML锁定Table中某一列

1.

2.

3.

 function ChangeTable()

   {
var type = document.getElementById("ddl_ReportType").value.Trim(); if (type == )
{
document.getElementById("TableInfo").innerHTML = TableYX();
}
else if (type == )
{
document.getElementById("TableInfo").innerHTML = TablePY();
} else if (type == )
{
document.getElementById("TableInfo").innerHTML = TableGL();
}
else if (type == )
{
document.getElementById("TableInfo").innerHTML = TableLG();
}
} function TableGL()
{
var str = "<table name='tblSlt' width='100%' border='0' runat='server' align='center' cellpadding='0' cellspacing='1' bgcolor='#999999'>";
str += " <tbody><tr>"; str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>项目名称</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>原工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>修改后工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'></td>"; str += " </tr></tbody>";
str += " <tr>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'>" +
"<select id='SltId' name='SltName' style='width:100%;'> <option value='0' selected='selected'>请选择</option>" +
" <option value='JBGZ_'>工资</option> <option value='BLGZ_'>保留工资</option> <option value='DTF_'>独贴</option> " +
"<option value='MTF_'>民贴</option> <option value='QTY_'>其他</option> <option value='KCBJ_'>扣病事假</option>" +
"<option value='YLJ_'>养老金</option> <option value='YBJ_'>医保金</option> <option value='SBJ_'>失保金</option>" +
"<option value='GJJ_'>公积金</option> <option value='BFGJJ_'>补充公积金</option> <option value='GHF_'>工会费</option>" +
"<option value='QT_'>其他</option> <option value='GTS_'>个调税</option></select> </td>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJBGZ' /></td>"; //onchange=\"AllUpdate('JBGZ')\"
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJiangJ' /></td>" //onchange=\"AllUpdate('JiangJ')\"
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;' align='center'><input type='button' style='background:url(../../../images/Button/Button_Change.jpg); width:55px; Height:30px;' onclick =\"AllUpdate('JZZYBF')\" id='JZZYBF' /></td>"; str += " </tr> ";
str += "</table>";
return str;
} function TableLG()
{
var str = "<table name='tblSlt' width='100%' border='0' runat='server' align='center' cellpadding='0' cellspacing='1' bgcolor='#999999'>";
str += " <tbody><tr>"; str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>项目名称</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>原工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>修改后工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'></td>"; str += " </tr></tbody>";
str += " <tr>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'>" +
"<select id='SltId' name='SltName' style='width:100%;'> <option value='0' selected='selected'>请选择</option> " +
"<option value='JBGZ_'>生活费</option> <option value='FTF_'>社保金</option> " +
" <option value='CTF_'>公积金</option><option value='DTF_'>独贴</option> <option value='MTF_'>民贴</option>" +
"<option value='QTY_'>其他</option> <option value='YLJ_'>养老金</option> <option value='YBJ_'>医保金</option>" +
"<option value='SBJ_'>失业金</option> <option value='GJJ_'>公积金</option> <option value='QT_'>其他</option> </select></td>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJBGZ' /></td>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJiangJ' /></td>"
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;' align='center'><input type='button' style='background:url(../../../images/Button/Button_Change.jpg); width:55px; Height:30px;' onclick =\"AllUpdate('JZZYBF')\" id='JZZYBF' /></td>" str += " </tr> ";
str += "</table>";
return str;
} function TableYX()
{
var str = "<table name='tblSlt' width='100%' border='0' runat='server' align='center' cellpadding='0' cellspacing='1' bgcolor='#999999'>";
str += " <tbody><tr>"; str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>项目名称</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>原工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>修改后工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'></td>"; str += " </tr></tbody>";
str += " <tr>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><select id='SltId' name='SltName' style='width:100%;'>" +
" <option value='0' selected='selected'>请选择</option> <option value='JBGZ_'>工资</option> <option value='BLGZ_'>保留工资</option> " +
" <option value='JiangJ_'>奖金</option> <option value='JZZYBF_'>加、值、中夜班费</option> <option value='DTF_'>独贴</option> " +
"<option value='MTF_'>民贴</option> <option value='FTF_'>饭贴</option> <option value='CTF_'>车贴</option> " +
"<option value='QTY_'>其他一</option> <option value='QTE_'>其他二</option> <option value='KCBJ_'>扣病事假</option> " +
"<option value='YLJ_'>养老金</option> <option value='YBJ_'>医保金</option> <option value='SBJ_'>失保金</option>" +
" <option value='GJJ_'>公积金</option> <option value='BFGJJ_'>补充公积金</option> <option value='GHF_'>工会费</option>" +
"<option value='QT_'>其他</option> <option value='GTS_'>个调税</option> </select></td>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJBGZ' /></td>"; //onchange=\"AllUpdate('JBGZ')\"
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJiangJ' /></td>" //onchange=\"AllUpdate('JiangJ')\"
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;' align='center'><input type='button' style='background:url(../../../images/Button/Button_Change.jpg); width:55px; Height:30px;' onclick =\"AllUpdate('JZZYBF')\" id='JZZYBF' /></td>"; str += " </tr> ";
str += "</table>";
return str;
} function TablePY() {
var str = "<table name='tblSlt' width='100%' border='0' runat='server' align='center' cellpadding='0' cellspacing='1' bgcolor='#999999'>";
str += " <tbody><tr>"; str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>项目名称</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>原工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'>修改后工资</td>";
str += " <td class='ListTitle' style='font-weight: bolder;width:50px;' background='../../../images/Main/tableTitle_bg.jpg'></td>"; str += " </tr></tbody>";
str += " <tr>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'> " +
"<select id='SltId' name='SltName' style='width:100%;'> <option id='selected' value='0' selected='selected'>请选择</option>" +
" <option value='JBGZ_'>工资</option> <option value='JiangJ_'>奖金</option> <option value='JZZYBF_'>加、值、中夜班费</option> " +
"<option value='DTF_'>午餐费</option> <option value='MTF_'>晚餐费</option> <option value='FTF_'>夜宵费</option> " +
" <option value='QTY_'>其他</option> <option value='KCBJ_'>扣病事假</option> <option value='YLJ_'>养老金</option>" +
" <option value='YBJ_'>医保金</option> <option value='SBJ_'>失保金</option> <option value='GJJ_'>公积金</option> " +
"<option value='QT_'>其他</option> <option value='GTS_'>个调税</option> </select></td>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJBGZ' /></td>";
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;'><input type='text' maxlength = '12' style='width:100%;' class='tdinput' id='inputJiangJ' /></td>"
str += " <td class='tdColInputCenter' style='font-weight: bolder;width:50px;' align='center'><input type='button' style='background:url(../../../images/Button/Button_Change.jpg); width:55px; Height:30px;' onclick =\"AllUpdate('JZZYBF')\" id='JZZYBF' /></td>"; str += " </tr> ";
str += "</table>";
return str;
} function aa()
{
var a = document.getElementById("cc").scrollTop;
var b = document.getElementById("cc").scrollLeft;
document.getElementById("dd").scrollTop = a;
document.getElementById("hh").scrollLeft = b;
} function AllUpdate()
{
var select = document.getElementById("SltId").value; var table = document.getElementById("tblSalaryDetail"); var CountNum = ; var NowSal = document.getElementById("inputJBGZ").value.Trim();
var ModifedSal = document.getElementById("inputJiangJ").value.Trim(); if (table != null)
{
if (select == "") //默认'请选择'的value值为'0';
{
alert("请选择你需要修改的项目!");
}
else if (NowSal == "" && ModifedSal == "") {
alert("请在对应的位置,输入原工资和修改后的工资!");
}
else if (NowSal == "") {
alert("请输入原工资!");
}
else if (ModifedSal == "") {
alert("请输入修改后的工资!");
}
else
{
//获取表格行数
var tableCount = table.rows.length; for (var row = ; row < tableCount; row++) {
var rowIndex = table.rows[row - ];
var textinput = rowIndex.getElementsByTagName("input"); for (var i = ; i < textinput.length; i++) {
if (textinput[i].value == NowSal && (textinput[i].id.indexOf(select) > -)
{
textinput[i].value = ModifedSal;
CountNum++;
}
}
CalculateTotalSalary("", row);
} if (CountNum == ) {
alert("没有找到与你要求相符的数据 ! \n 请您重新输入进行查找。");
}
}
}
else
{
alert("没有可更新的数据!");
}
}
上一篇:Codeforces Codeforces Round #316 (Div. 2) C. Replacement set


下一篇:2016 "Bird Cup" ICPC7th@ahstu--“波导杯”安徽科技学院第七届程序设计大赛