这样随机显示图片如何实现

ljp3000 2005-07-20 01:43:58
如果一定要用这样的方法变换图片:<img src="auto.asp">

假设有1.gif, 2.gif 两张图片
auto.asp里随机决定显示哪张图片
这个auto.asp应该怎么写?谢谢
...全文
241 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
sharing 2005-10-18
  • 打赏
  • 举报
回复
收起来
lyh4226 2005-07-21
  • 打赏
  • 举报
回复
1,2楼的可以哦!
ljp3000 2005-07-21
  • 打赏
  • 举报
回复
嗯,Response.Redirect ,正是我要的.
谢谢 wzhiyuan!
wzhiyuan 2005-07-21
  • 打赏
  • 举报
回复
<%
Randomize
i=int(rnd*2+1)
Response.Redirect i&".gif"
%>
kakalong 2005-07-21
  • 打赏
  • 举报
回复
<%
Randomize

i=Int((5 * Rnd) + 1)' 产生 1 到 5 之间的随机数

Select Case i
Case "1"
response.write "<img src=http://www.13778.com/images/1.gif>" '换成自己的路径
Case "2"
response.write "<img src=http://www.13778.com/images/2.gif>"
Case "3"
response.write "<img src=http://www.13778.com/images/3.gif>"
Case "4"
response.write "<img src=http://www.13778.com/images/4.gif>"
Case "5"
response.write "<img src=http://www.13778.com/images/5.gif>"
Case Else
response.write "<img src=http://www.13778.com/images/1.gif>"
End Select
%>


那就这样吧. 你再不会的话可能大家都没办法啊.
你还是先学学基础的吧
wzhiyuan 2005-07-21
  • 打赏
  • 举报
回复
mark
kingkuf 2005-07-20
  • 打赏
  • 举报
回复
Select Case循环呀!比较好用!
celect case (I)
KeyPress 2005-07-20
  • 打赏
  • 举报
回复
高,都高招。。。
renniliao 2005-07-20
  • 打赏
  • 举报
回复
广告轮显组件可以,用自己编的算法当然也可以。楼上几位说的不错。
ljp3000 2005-07-20
  • 打赏
  • 举报
回复
不对吧,大家,

<img src="auto.asp">
如果auto.asp就是
<%
response.write "2.gif"
%>
显然是不会显示图片的,因为"2.gif"会被当做图片的数据内容试图显示出来,
页不会当做文件名的去找2.gif吧?

  • 打赏
  • 举报
回复
还有就是用ASP的广告轮换控件
ljqhbt 2005-07-20
  • 打赏
  • 举报
回复
randize
xx=int(5*rand())
<img src="auto.asp?id=XX">
runtu 2005-07-20
  • 打赏
  • 举报
回复
up 上面的都可以`
白夜花寒 2005-07-20
  • 打赏
  • 举报
回复
用客户端脚本也可以的....

<html>
<head>
<script language="javascript">
function preload(imgObj,imgSrc){
eval(imgObj+'=new Image()');
eval(imgObj+'.src="'+imgSrc+'"');
}

function ini(){
//preload('imageA','14.jpg');
//preload('imageB','15.jpg');
//preload('imageC','16.jpg');
// preload('imageD','15.jpg');
//preload('imageE','14.jpg');
//preload('imageF','15.jpg');
//preload('imageG','14.jpg');
//preload('imageH','15.jpg');
//preload('imageI','14.jpg');
//preload('imageJ','15.jpg');
//preload('imageK','14.jpg');
//preload('imageL','15.jpg');
var theimage=new Array("14.jpg","15.jpg","16.jpg","2.jpg","8.jpg","11.jpg","22.jpg","23.jpg","33.jpg","35.jpg");
var the_img=document.getElementById("img1");
// the_img.src=theimage[9];
var thenum=Math.random();
thenum=thenum*10;
thenum=Math.floor(thenum);
the_img.src=theimage[thenum];
//getimgid();
}

function getimgid(){
var the_img=document.getElementById("img1");
the_img.src=(the_img.src==imageA.src)?imageB.src:imageA.src;

window.setTimeout("getimgid()",3000);
// the_img.src=imageA.src;
}

function img2small(){
}
</script>
</head>
<body onload='ini()'>
<img src='14.jpg' id='img1' width='200' style='filter:alpha(opacity=30)'/>

</body>
</html>
孟子E章 2005-07-20
  • 打赏
  • 举报
回复
Case 1

Case 2
kakalong 2005-07-20
  • 打赏
  • 举报
回复
<%
Randomize

i=Int((5 * Rnd) + 1)' 产生 1 到 5 之间的随机数

Select Case i
Case "1"
response.write "http://www.13778.com/images/1.gif" '换成自己的路径
Case "2"
response.write "http://www.13778.com/images/2.gif"
Case "3"
response.write "http://www.13778.com/images/3.gif"
Case "4"
response.write "http://www.13778.com/images/4.gif"
Case "5"
response.write "http://www.13778.com/images/5.gif"
Case Else
response.write "http://www.13778.com/images/1.gif"
End Select
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧