读书人

没办法+++++100分 复制运行下面的两部

发布时间: 2012-02-21 16:26:23 作者: rapoo

没办法+++++100分 复制运行下面的两部分HTML代码可以看到效果 替换下面JAVASCRIPT中的绝对路径
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<body>
<form id=form1 runat=server>
<table width= "38% " height= "50 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "1 " bgcolor= "#B7CEDC "> </td>
<td width= "332 " valign= "top " bgcolor= "#FFFFFF "> <div id= "ziliao6 ">
<table width= "283 " height= "283 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td align= "center " valign= "middle " > <a href= "http://product.danawa.com.cn/79731/pic.html "> <img src= "http://images1.danawa.com.cn/china_283/CAA/CEL20060531115138390.jpg " name= "prod_img " id= "prod_img " border= "0 " alt= "图片 "/> </a> </td>
</tr>
</table>
<!-- insert pic_total_count here -->
<script language= "JavaScript " type= "text/javascript ">
var iCount = 1;
var iEnd=0;
function ProdPic(url)
{
this.url = url;
}
var ProdPicList = new Array();
ProdPicList[0] = new ProdPic( "http://images1.danawa.com.cn/china_sImages2/CAA/CEL20060531115138390.jpg ");
ProdPicList[1] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557580.621478.jpg ");


ProdPicList[2] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557580.886834.jpg ");
ProdPicList[3] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.067359.jpg ");
ProdPicList[4] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.2674.jpg ");
ProdPicList[5] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.588347.jpg ");
ProdPicList[6] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.916552.jpg ");
ProdPicList[7] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.19166.jpg ");
ProdPicList[8] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.388924.jpg ");
ProdPicList[9] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.589709.jpg ");
ProdPicList[10] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.740137.jpg ");
ProdPicList[11] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558380.72252.jpg ");
ProdPicList[12] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558380.940921.jpg ");
ProdPicList[13] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.109084.jpg ");
ProdPicList[14] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.342582.jpg ");
ProdPicList[15] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.524367.jpg ");
ProdPicList[16] = new ProdPic( "http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.752372.jpg ");


function next()
{
if (iCount > = ProdPicList.length){
iCount = 0;//如果超出数组的长度就置为0


}
iEnd=iCount+4;//以4为步长进行递增
if(iEnd> ProdPicList.length){
iEnd=ProdPicList.length;//iEnd变量也不能超出数组的长度
}
if(ProdPicList.length <=4){
//do nothing
}else{
for(var i=1;iCount <iEnd;iCount++,i++){//开始每次的循环输出
document.getElementById( "img_prod "+i).src = ProdPicList[iCount].url;
}
}
}

function pre()
{
if(iCount==0){
iCount=ProdPicList.length-1;
}
iEnd=iCount-4;
if(iEnd <0){
iEnd=0;
}
if(ProdPicList.length <=4){
//do nothing
}else{
for(var i=1;iCount> iEnd;iCount--,i++){
document.getElementById( "img_prod "+i).src = ProdPicList[iCount].url;
}
}
}

function init(){
var arrayLength=ProdPicList.length;
if(arrayLength> 4){


arrayLength=4;
}
for(var i=0;i <arrayLength;i++){
var index=i+1;
document.getElementById( "img_prod "+index).src = ProdPicList[i].url;
}

}

function ShowImage(image_name) {
var url=document.getElementById(image_name).src.replace( "upload_50 ", "upload_283 ").replace( "china_sImages2 ", "china_283 ");
document.images[ "prod_img "].src =url;
}
</script>


[解决办法]
LZ是想做到什么?代码太长还没看
[解决办法]
问楼主,怎么个替换法?
[解决办法]
?
[解决办法]
!
[解决办法]
反应慢
[解决办法]
lz要问什么?
[解决办法]
明白了

[解决办法]
太长了,没敢看,楼猪想干吗?
[解决办法]

[解决办法]
图片名有规律点不用这么麻烦吧?
[解决办法]
原来楼主是要从数据库取数据给数组ProdPicList赋值……
[解决办法]
是用我说的方法么?
口水。。。。。。。。。
[解决办法]
我要显示的图片有多少是不一定的 所以这样写死这个数组并给个固定的值应用中意义不大 所有替换为从数据库中取啊
===================================================================================
我在LZ另外一个贴上说的方法不知道LZ试过没有
前台放个隐藏的listbox,在后台绑定text属性为你数据库里图片的路径名.
前台这样取:
<script language= "javascript ">
<!--
var ProdPicList=new Array(); //定义一个JS数组 我忘了要不要声明数组个数了
var list=document.getElementById( "ListBox1 ");//list对象就是你绑定的listbox
var listindex=list.length;
for(int i=0;i <listindex-1;i++)
{
ProdPicList[i]=list.options[i].text;
}
-->


</script>
============================
这样应该是可行的,我晚上有空帮你弄下.

读书人网 >asp.net

热点推荐