yuanquan001 发表于 2007-12-19 13:35

求助斑竹,为什么显示不出图片来了?

<script language="javascript">
var yzm=Math.floor((Math.random()*10000))
a=Math.floor(yzm/1000);
b=Math.floor(yzm/100)-a*10;
c=Math.floor(yzm/10)-a*100-b*10;
d=Math.floor(yzm)-a*1000-b*100-c*10
function chuan()
{
var c=document.form1.yzm1.value

if(c!=yzm)
{
        alert("验证码错误!");
        document.form1.yzm1.value="";
   return false
}
}
</script>
</head>

<body>
<form name="form1" method="post"  action="http://www.baidu.com" onSubmit="return chuan()">
验证码:<input type="text" name="yzm1" /><img src="[color=Red]image/<script>document.write(a)</script>.jpg[/color]" /><img src="[color=Red]image/<script>document.write(b)</script>.[/color]jpg" /><img src="[color=Red]image/<script>document.write(c)</script>.[/color]jpg" /><img src="[color=Red]image/<script>document.write(d)</script>.[/color]jpg "/>
<br />
<input type="submit" name="submit1" value="提交" />
</form>

渚薰 发表于 2007-12-19 15:06

用script的document.write干吗???

yuanquan001 发表于 2007-12-19 15:16

输出变量。然后才能调用图片。我是这样想的。

yuanquan001 发表于 2007-12-19 15:24

可是,不用document.write图片照样输不出啊

渚薰 发表于 2007-12-19 18:31

在浏览器里直接输入图片地址,看看图片能不能显示,不能显示就是路径的问题

yuanquan001 发表于 2007-12-20 08:55

哦谢谢,解决了,是document.write的位置写错了

页: [1]

编程论坛