ASP怎么用javascript在td里显示!
<script>functiontest(){vara="aaaaa.doc|bbb.txt|ccc.rar";varb=a.split("|");for(varj=0;...
<script>
function test(){
var a="aaaaa.doc|bbb.txt|ccc.rar";
var b = a.split("|");
for(var j=0;j<b.length;j++)
{
for(var k=j+1;k<b.length;k++)
{
if(b[j]==b[k])
{
b[k]="";
}
}
}
var path =new Array();
var t=0;
for(var m=0;m<b.length;m++)
{
if (b[m]!="")
{
path[t]=b[m];
t++;
}
}
var fileEXT;
var fstring;
for(var i=0;i<path.length;i++)
{
fileEXT=path[i].substr(path[i].length-4);
if(fileEXT==".png") {
document.write("<img src='Images/png.gif' width='16' height='16'>") ;}
else if (fileEXT==".rar"){
document.write("<img src='Images/rar.gif' width='16' height='16'>");}
else if (fileEXT==".zip") {
document.write("<img src='Images/zip.gif' width='16' height='16'>");}
else if (fileEXT==".jpg") {
document.write("<img src='Images/jpg.gif' width='16' height='16'>");}
else if (fileEXT==".gif") {
document.write("<img src='Images/gif.gif' width='16' height='16'>");}
else if (fileEXT==".doc") {
document.write("<img src='Images/doc.gif' width='16' height='16'>");}
else if (fileEXT==".xls"){
document.write("<img src='Images/xls.gif' width='16' height='16'>");}
else if (fileEXT==".txt"){
document.write("<img src='Images/txt.gif' width='16' height='16'>");}
if (path[i]!=null){
document.write("<a href='downfile.asp?filename=\SendUploadFiles\'"+path[i]+" target='_blank' style='text-decoration:none;' >"+path[i]+"</a> <a href='?action=3&delect="+path[i]+"&path=<%=session("sendfilepath")%>'>删除</a><br>");}
}
document.getElementById('fujian').innerHTML=;
}
</script>
<body>
<table width="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">附件:</td>
<td width="3%" bgcolor="#f2f2f2"> </td>
<td width="32%" height="30" bgcolor="#f2f2f2" id="fujian">
</td>
</tr>
</table>
</body>
怎么把上面要显示的内容经ID=fujian传到td里面显示,显示情况如下:
aaaaa.doc 删除
bbb.txt 删除
ccc.rar 删除 展开
function test(){
var a="aaaaa.doc|bbb.txt|ccc.rar";
var b = a.split("|");
for(var j=0;j<b.length;j++)
{
for(var k=j+1;k<b.length;k++)
{
if(b[j]==b[k])
{
b[k]="";
}
}
}
var path =new Array();
var t=0;
for(var m=0;m<b.length;m++)
{
if (b[m]!="")
{
path[t]=b[m];
t++;
}
}
var fileEXT;
var fstring;
for(var i=0;i<path.length;i++)
{
fileEXT=path[i].substr(path[i].length-4);
if(fileEXT==".png") {
document.write("<img src='Images/png.gif' width='16' height='16'>") ;}
else if (fileEXT==".rar"){
document.write("<img src='Images/rar.gif' width='16' height='16'>");}
else if (fileEXT==".zip") {
document.write("<img src='Images/zip.gif' width='16' height='16'>");}
else if (fileEXT==".jpg") {
document.write("<img src='Images/jpg.gif' width='16' height='16'>");}
else if (fileEXT==".gif") {
document.write("<img src='Images/gif.gif' width='16' height='16'>");}
else if (fileEXT==".doc") {
document.write("<img src='Images/doc.gif' width='16' height='16'>");}
else if (fileEXT==".xls"){
document.write("<img src='Images/xls.gif' width='16' height='16'>");}
else if (fileEXT==".txt"){
document.write("<img src='Images/txt.gif' width='16' height='16'>");}
if (path[i]!=null){
document.write("<a href='downfile.asp?filename=\SendUploadFiles\'"+path[i]+" target='_blank' style='text-decoration:none;' >"+path[i]+"</a> <a href='?action=3&delect="+path[i]+"&path=<%=session("sendfilepath")%>'>删除</a><br>");}
}
document.getElementById('fujian').innerHTML=;
}
</script>
<body>
<table width="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">附件:</td>
<td width="3%" bgcolor="#f2f2f2"> </td>
<td width="32%" height="30" bgcolor="#f2f2f2" id="fujian">
</td>
</tr>
</table>
</body>
怎么把上面要显示的内容经ID=fujian传到td里面显示,显示情况如下:
aaaaa.doc 删除
bbb.txt 删除
ccc.rar 删除 展开
1个回答
展开全部
<td width="32%" height="30" bgcolor="#f2f2f2" id="fujian">
<script>test();</script>
</td>
这个是直接打印write的,还可以用对象document.getElementById('fujian').innerHTML改变值!
但是上面的js代码就需要修改!
把所有document.write()都改为变量保存如:strhtml+="内容"
到最后用:document.getElementById('fujian').innerHTML=strhtml;
<script>test();</script>
</td>
这个是直接打印write的,还可以用对象document.getElementById('fujian').innerHTML改变值!
但是上面的js代码就需要修改!
把所有document.write()都改为变量保存如:strhtml+="内容"
到最后用:document.getElementById('fujian').innerHTML=strhtml;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询