为什么我的asp代码加载后,打开页面速度很慢
这是一个动态添加行的js调用,在js里又调用了下面这一段,我测试了,就是因为StrTemp(红色部分)的加载,打开页面速度特别慢,可是我不知道怎么改合适。请高手指教js:
<script type="text/javascript">
var ii=0;
function addTable()
{
ii=ii+1;
var tab = document.getElementById("tb1") ;
//表格行数
var rows = tab.rows.length ;
if(rows<=8)
{
newTr=document.getElementById("tb1").insertRow();
var newTd0 = newTr.insertCell();
var newTd1 = newTr.insertCell();
var newTd2 = newTr.insertCell();
var newTd3 = newTr.insertCell();
var newTd4 = newTr.insertCell();
var newTd5 = newTr.insertCell();
var newTd6 = newTr.insertCell();
var newTd7 = newTr.insertCell();
var newTd8 = newTr.insertCell();
var newTd9 = newTr.insertCell();
var newTd10 = newTr.insertCell();
var newTd11 = newTr.insertCell();
var newTd12 = newTr.insertCell();
var newTd13 = newTr.insertCell();
var newTd14 = newTr.insertCell();
var newTd15 = newTr.insertCell();
newTd0.className='category';
newTd1.className='category';
newTd2.className='category';
newTd3.className='category';
newTd4.className='category';
newTd5.className='category';
newTd6.className='category';
newTd7.className='category';
newTd8.className='category';
newTd9.className='category';
newTd10.className='category';
newTd11.className='category';
newTd12.className='category';
newTd13.className='category';
newTd14.className='category';
newTd15.className='category';
newTd0.innerHTML="<img src='../images/folder_close.gif' style='cursor:hand' onClick='collapseall(this)'/>";
newTd1.innerHTML="<input name='xh"+tab.rows.length+"' id='xh"+tab.rows.length+"' type='text' size='5' value='' >";
switch(rows)
{
case 1:
newTd2.innerHTML="<%=ShowTable(2)%>"
break;
case 2:
newTd2.innerHTML="<%=ShowTable(3)%>"
break;
case 3:
newTd2.innerHTML="<%=ShowTable(4)%>"
break;
case 4:
newTd2.innerHTML="<%=ShowTable(5)%>"
break;
case 5:
newTd2.innerHTML="<%=ShowTable(6)%>"
break;
case 6:
newTd2.innerHTML="<%=ShowTable(7)%>"
break;
case 7:
newTd2.innerHTML="<%=ShowTable(8)%>"
break;
case 8:
newTd2.innerHTML="<%=ShowTable(9)%>"
break;
}
newTd3.innerHTML="<input name='fl"+tab.rows.length+"' id='fl"+tab.rows.length+"' type='text' size='8' value=''>"
newTd4.innerHTML="<input name='zbh"+tab.rows.length+"' id='zbh"+tab.rows.length+"' type='text' size='8' value=''>"
newTd5.innerHTML="<input name='gs"+tab.rows.length+"' id='gs"+tab.rows.length+"' type='text' size='8' onkeyup=\"$('je"+tab.rows.length+"').value=parseFloat($('dj"+tab.rows.length+"').value*this.value).toFixed(2)\"/>"
newTd6.innerHTML="<input name='dw"+tab.rows.length+"' id='dw"+tab.rows.length+"' type='text' size='8' value=''>"
newTd7.innerHTML="<input name='sl"+tab.rows.length+"' id='sl"+tab.rows.length+"' type='text' size='8' value=''>"
newTd8.innerHTML="<input name='xj"+tab.rows.length+"' id='xj"+tab.rows.length+"' type='text' size='8' value=''>"
newTd9.innerHTML="<input name='dj"+tab.rows.length+"' id='dj"+tab.rows.length+"' type='text' size='8' value='' >"
newTd10.innerHTML="<input name='je"+tab.rows.length+"' id='je"+tab.rows.length+"' type='text' size='8' value='' >"
newTd11.innerHTML="<input name='qxjxf"+tab.rows.length+"' id='qxjxf"+tab.rows.length+"' type='text' size='8' value=''>"
newTd12.innerHTML="<input name='gsf"+tab.rows.length+"' id='gsf"+tab.rows.length+"' type='text' size='8' value=''>"
newTd13.innerHTML="<input name='beizhu"+tab.rows.length+"' id='beizhu"+tab.rows.length+"' type='text' size='8' value=''>"
newTd14.innerHTML="<input name='hj"+tab.rows.length+"' id='hj"+tab.rows.length+"' type='text' size='8' onFocus=\"this.value=parseFloat($('je"+tab.rows.length+"').value)+parseFloat($('qxjxf"+tab.rows.length+"').value)+parseFloat($('gsf"+tab.rows.length+"').value)\"/>"
}
else
{
alert("对不起,此张料单最多只能开8笔!")
}
//alert(rows);
document.getElementById("num").value=rows;
}
</script>
<script>
function rdl_delRow(e){
event.cancelBubble=true;
with (event.srcElement.parentElement) {
if (tagName.toLowerCase()=="tr") tb1.deleteRow(rowIndex);
}
}
</script>
asp调用::
<%
Function ShowTable(Row)
StrTemp="<select size='1' name='select"&Row&"' id='select"&Row&"' onChange='fl"&Row&".value=this.options[select"&Row&".selectedIndex].fl"&Row&";zbh"&Row&".value=this.options[select"&Row&".selectedIndex].zbh"&Row&";dw"&Row&".value=this.options[select"&Row&".selectedIndex].dw"&Row&";sl"&Row&".value=this.options[select"&Row&".selectedIndex].sl"&Row&";xj"&Row&".value=this.options[select"&Row&".selectedIndex].xj"&Row&";dj"&Row&".value=this.options[select"&Row&".selectedIndex].dj"&Row&";qxjxf"&Row&".value=this.options[select"&Row&".selectedIndex].qxjxf"&Row&";gsf"&Row&".value=this.options[select"&Row&".selectedIndex].gsf"&Row&";beizhu"&Row&".value=this.options[select"&Row&".selectedIndex].beizhu"&Row&";'><option selected value=''></option>"
Set rs=Conn.execute("SELECT id,fl,zbh,dw,sl,xj,dj,qxjxf,gsf,mcjgg,beizhu FROM jgb Where mcjgg<>'' ORDER BY id ASC")
Do While Not rs.Eof
StrTemp=StrTemp&"<option value='"&rs("mcjgg")&"' select"&Row&"='"&rs("mcjgg")&"' fl"&Row&"='"&rs("fl")&"' zbh"&Row&"='"&rs("zbh")&"' dw"&Row&"='"&rs("dw")&"' sl"&Row&"='"&rs("sl")&"' xj"&Row&"='"&rs("xj")&"' dj"&Row&"='"&rs("dj")&"' qxjxf"&Row&"='"&rs("qxjxf")&"' gsf"&Row&"='"&rs("gsf")&"' beizhu"&Row&"='"&rs("beizhu")&"'> "&rs("mcjgg")&" </option> "
rs.MoveNext
Loop
rs.Close
Set rs=Nothing
StrTemp=StrTemp&"</select>"
ShowTable=StrTemp
End Function
%>