帮忙,看看动态添加后的文本框焦点问题
var po_num=1;
function AddPO_FN(){
window.po_td.innerHTML =window.po_td.innerHTML+ " <br> <input name= 'po "+po_num+ " ' type= 'text ' class= 'InputText2 ' id= 'po "+po_num+ " ' size= '15 ' maxlength= '15 '> "
eval( "document.form1.po "+po_num).focus();
po_num++;
}
///////////////
当调用函数之后,文本框添加无问题,可是焦点缺找不到,这是为什么呢?
po_td是一个单元格 <td id= "po_td ">
谢谢大家
------解决方案--------------------LZ 一开始又没说需要多个,哈
弄个能用的给 LZ,客户的需求确实很善变,不过只有变化才能产生效益!
IE 6 下测试可用,L@_@K!
<body>
<table>
<tr>
<td> 1 </td>
<td id= "po_td "> </td>
</tr>
<tr>
<td> 2 </td>
<td> 3 </td>
</tr>
</table>
<input type= "button " id= "btnAdd " value= "Add " />
<script type= "text/javascript ">
<!--
var po_num = 1;
function AddPO_FN()
{
document.all.po_td.innerHTML += " <br /> <input name= 'po "+po_num+ " ' type= 'text ' class= 'InputText2 ' id= 'po "+po_num+ " ' size= '15 ' maxlength= '15 '> ";
window.setTimeout(setFocus, 100);
}
function setFocus()
{
eval( "document.all.po "+po_num).focus();
po_num++;
}
document.all.btnAdd.onclick = AddPO_FN;
//-->
</script>
</body>