以下代码是一段asp查询的记录集,点击工号在下面出现了相关的信息。
- VBScript code
<% i=1 'if RS.recordcount>0 then do while not RS.eof %> <tr> <td align="center" bgcolor="#EEEEEE" onclick="show(<%=i%>)"><%=RS("gid")%></td> <td align="center" bgcolor="#EEEEEE"><%=RS("pl_name")%></td> <td align="center" bgcolor="#EEEEEE"><%=RS("pl_money")%></td> <td align="center" bgcolor="#EEEEEE"><a href="roommember.asp?roomid=<%=RS("pl_room")%>" ><%=RS("pl_room")%></a></td> <td align="center" bgcolor="#EEEEEE"><%=RS("pl_joindate")%></td> <td align="center" bgcolor="#EEEEEE"><%=RS("pl_yesdate")%></td> </tr> <tr> <td colspan="6" bgcolor="#EEEEEE"> <div class="pl_memberinfo" id=No<%=i%> style="display:none"> <form id="form<%=i%>" name="form<%=i%>" method="post" action=""> <div class="pl_close"><span onclick="noshow(<%=i%>)">×</span></div> <ul> <li> 工号:<a id=gh onClick="change();"><%=RS("gid")%></a><a id=gid></a></li> <li>姓名:<a id=pl_name><%=RS("pl_name")%></a></li> <li>性别:<a id=pl_sex><%=RS("pl_sex")%></a></li> <li>出生日期:<a id=pl_birthday ><%=RS("pl_birthday")%></a></li> <li>在职:<a id=pl_jobon><%=RS("pl_jobon")%></a></li> <li>入职日期:<a id=pl_joindate ><%=RS("pl_joindate")%></a></li> <li>离职日期:<a id=pl_outdate ><%=RS("pl_outdate")%></a></li> <li>宿舍编号:<a id=pl_room ><%=RS("pl_room")%></a></li> <li>入住日期:<a id=pl_joinroom ><%=RS("pl_joinroom")%></a></li> <li>离宿日期:<a id=pl_outroom ><%=RS("pl_outroom")%></a></li> <li>正式员工:<a id=pl_yes ><%=RS("pl_yes")%></a></li> <li>转正日期:<a id=pl_yesdate ><%=RS("pl_yesdate")%></a></li> <li>月薪:<a id=pl_money ><%=RS("pl_money")%></a></li> <li>天制:<a id=pl_monthday ><%=RS("pl_monthday")%></a></li> <li>日制:<a id=pl_dayhour><%=RS("pl_dayhour")%></a></li> <li >加班费:<a id=pl_overtime><%=RS("pl_overtime")%></a></li> <li>工资期限:<a id=pl_moneytime><%=RS("pl_moneytime")%></a></li> <li>户籍地址:<a id=pl_add ><%=RS("pl_add")%></a></li> <li>身份证:<a id=pl_code ><%=RS("pl_code")%></a></li> <li>其它信息:<a id=pl_info><%=RS("pl_info")%></a></li> <li><a id="pl_submit" class="pl_submit"> /*点击工号修改职工信息*/ </a> </li> </ul> </form> </div> </td> </tr> <% i=i+1 RS.movenext Loop %>
我想在下面的详细信息循环页面点击工号,即点击工号:<a id=gh onClick="change();">后,所有的a自动替换成输入框,以下是代码:
- JScript code
//文字变输入框效果 function change() { gid.innerHTML=gh.innerText; gh.innerHTML=""; pl_name.innerHTML=pl_name.innerText.replace(pl_name.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_name.innerText+">"); pl_sex.innerHTML=pl_sex.innerText.replace(pl_sex.innerText,"<select name='pl_sex' id='pl_sex'><option value='1'>男</option><option value='0'>女</option><option value="+pl_sex.innerText+" selected='selected'>"+pl_sex.innerText+"</option></select>"); pl_birthday.innerHTML=pl_birthday.innerText.replace(pl_birthday.innerText,"<input size='12' type=text onClick='WdatePicker()' id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_birthday.innerText+">"); pl_jobon.innerHTML=pl_jobon.innerText.replace(pl_jobon.innerText,"<select name='pl_jobon' id='pl_jobon'><option value='1'>是</option><option value='0'>否</option><option value="+pl_jobon.innerText+" selected='selected'>"+pl_jobon.innerText+"</option></select>"); pl_joindate.innerHTML=pl_joindate.innerText.replace(pl_joindate.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" onClick='WdatePicker()' value="+pl_joindate.innerText+">"); pl_outdate.innerHTML=pl_outdate.innerText.replace(pl_outdate.innerText,"<input size='12' type=text onClick='WdatePicker()' id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_outdate.innerText+">"); pl_room.innerHTML=pl_room.innerText.replace(pl_room.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_room.innerText+">"); pl_joinroom.innerHTML=pl_joinroom.innerText.replace(pl_joinroom.innerText,"<input size='12' type=text onClick='WdatePicker()' id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_joinroom.innerText+">"); pl_outroom.innerHTML=pl_outroom.innerText.replace(pl_outroom.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" onClick='WdatePicker()' value="+pl_outroom.innerText+">"); pl_yes.innerHTML=pl_yes.innerText.replace(pl_yes.innerText,"<select name='pl_yes' id='pl_yes'><option value='1'>是</option><option value='0'>否</option><option value="+pl_yes.innerText+" selected='selected'>"+pl_yes.innerText+"</option></select>"); pl_yesdate.innerHTML=pl_yesdate.innerText.replace(pl_yesdate.innerText,"<input size='12' onClick='WdatePicker()' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_yesdate.innerText+">"); pl_money.innerHTML=pl_money.innerText.replace(pl_money.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_money.innerText+">"); pl_monthday.innerHTML=pl_monthday.innerText.replace(pl_monthday.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_monthday.innerText+">"); pl_dayhour.innerHTML=pl_dayhour.innerText.replace(pl_dayhour.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_dayhour.innerText+">"); pl_overtime.innerHTML=pl_overtime.innerText.replace(pl_overtime.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_overtime.innerText+">"); pl_moneytime.innerHTML=pl_moneytime.innerText.replace(pl_moneytime.innerText,"<input size='12' onClick='WdatePicker()' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_moneytime.innerText+">"); pl_add.innerHTML=pl_add.innerText.replace(pl_add.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_add.innerText+">"); pl_code.innerHTML=pl_code.innerText.replace(pl_code.innerText,"<input size='12' type=text id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_code.innerText+">"); pl_info.innerHTML=pl_info.innerText.replace(pl_info.innerText,"<textarea cols='25' id="+event.srcElement.id+" name="+event.srcElement.id+" value="+pl_info.innerText+">"); pl_submit.innerHTML=pl_submit.innerText.replace(pl_submit.innerText,"<input type='submit' name='button' id='button' value='提交' />"); }