我做了这个片段:
- 文件验证码.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
setInterval(function(){chrono('t');},1000);
</script>
<?php
include('function.php');
session_start();
global $list;
$list= captcha_list($_SESSION['id']);
if (isset($_POST['know'])){
?>
<script>
inte = 0;
var string ='<?php
$str='';
$x=sizeof($list);
for($j=0;$j < $x;$j++)
{
for($i=0;$i < 7;$i++)
{
$str=$str.$list[$j][$i].';';
}
}
echo $str.$list[$x-1];
?>';
var count='<?php
$x1=sizeof($list);
echo $x1;
?>';
var table =string.split(';');
var longuer=table.length-1;
currentElement=15;
document.getElementById("im").src=table[currentElement];
</script>
<?php
}
?>
<script>
function chrono(id){
inte= parseInt(document.getElementById(id).innerHTML,10);
var string ='<?php
$str='';
$x=sizeof($list);
for($j=0;$j < $x;$j++)
{
for($i=0;$i < 7;$i++)
{
$str=$str.$list[$j][$i].';';
}
}
echo $str.$list[$x-1];
?>';
var count='<?php
$x1=sizeof($list);
echo $x1;
?>'
var table =string.split(';');
var longuer=table.length-1;
if ( typeof this.currentElement == 'undefined' ) this.currentElement = 1;
switch(inte)
{
case 0:
document.getElementById(id).innerHTML='7';
if(currentElement==count*7-6){
currentElement=1;
}else{
currentElement+=7;
}
document.getElementById("im").src=table[currentElement];
break;
case 1:
document.getElementById(id).innerHTML='0';
break;
case 2:
document.getElementById(id).innerHTML='1';
break;
case 3:
document.getElementById(id).innerHTML='2';
break;
case 4:
document.getElementById(id).innerHTML='3';
break;
case 5:
document.getElementById(id).innerHTML='4';
break;
case 6:
document.getElementById(id).innerHTML='5';
break;
case 7:
document.getElementById(id).innerHTML='6';
break;
default:
break;
}
};
</script>
</head>
<body style="background-image:url(paper_03.png)" >
<form name="form_2" style="background-image:url(paper_02.png);position: absolute; top:30px; left: 200px; width: 500px; height: 500px;" method="post" >
<CENTER>
<table style="position: relative; top:30px;" >
<tr><td colspan=4><label>Image will be refresh in <label id="t" name="t"> 7 </label> seconds
</label></td><td></td></tr>
<tr><td height=200px ><label>Image </label></td><td></td><td height=200px colspan=2><input type="image" id="im" src=<?php echo $list[0]['captcha'];?> style=" height=150px" /> </td></tr>
<tr><td height=200px><label>Text </label></td><td colspan=3 height=200px><input type="text" name="cap" style="width: 400px" /> </td></tr>
<tr><td></td><td><input type="submit" name="answer" value="SUBMIT ANSWER" style="height:200%;background-image:url(paper_03.png)"/> </td><td><input type="submit" name="know" value="DON'T KNOW" style="height:200%; background-image:url(paper_03.png)"/> </td><td><input type="submit" name="pause" value="SUBMIT AND PAUSE" style="height:200%;background-image:url(paper_03.png)"/> </td>
</tr>
</table>
</CENTER>
</form>
</body>
<footer>
<?php
include('header_footer/footer.php');
?>
</footer>
</html>
图像一个接一个地传递,但如果我单击“知道”按钮,页面刷新并显示第一张图像。我想如果我点击“知道”下一个图像将显示。
- 错误是什么?
- 我该如何解决?