Hi,
I have a Experiment which records value for each image depending on whether target is present or not, images scroll on the screen pause for 3 seconds and scroll off.I have placed all the images in an array and corresponding to it i have created an image ID array which has 0 and 1 values, 0-target 1-No target, depending on this 0 and 1 are recorded in the database
i have a scroll function which is called as soon as the Experiment starts,i assigned image ID corresponding to its image. when the experiment runs the image id of next image is recorded to the current image. appreciate any ideas where i went wrong.
Here is my code..
var slideimages=new Array("images\bag001.jpg","images\bag002.jpg","images\bag003.jpg"............................................"images\bag200.jpg")
var img_id=new Array("0","0","1","0","0","0","0","0","0","1","1","0","0","1","0","0","0","0",
"1","1","0","0","1","0","0","0","0","1","1","0","0","1","0","0","0","0","1","0","0","0",
"0","1","0","1","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1");
var speed=10
var ie = document.all;
var dom=document.getElementById;
if (slideimages.length>1)
i=2
else
i=0
function move1(whichlayer)
{
tlayer=eval(whichlayer)
if (tlayer.right>0&&tlayer.right<=5){
tlayer.right=0
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(scrollerdiv2)",pausebetweenimages)
disable_enable()
flag = 1
if(flag == 1)
setTimeout("disp(flag)",2999)
return
}
document.form.button.disabled=false
if (tlayer.right>=tlayer.document.width*-1){
tlayer.right-=5
setTimeout("move1(tlayer)",100)
disable_enable()
}
else{
tlayer.right=parseInt(scrollerwidth)+5
imgid = img_id[i]
imgname = tlayer.document.write(slideimages[i])
tlayer.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
if(count>=201)
location.href='endofexperiment.php';
}
function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.right>0&&tlayer2.right<=5){
tlayer2.right=0
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(scrollerdiv2)",pausebetweenimages)
disable_enable()
flag = 1
if(flag ==1)
setTimeout("disp(flag)",3000)
return
}
document.form.button.disabled=false
if (tlayer2.right>=tlayer2.document.width*-1){
tlayer2.right-=5
setTimeout("move2(tlayer2)",100)
disable_enable()
}
else{
tlayer2.right=parseInt(scrollerwidth)+5
imgid = img_id[i]
imgname = tlayer2.document.write(slideimages[i])
tlayer2.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
if(count>=201)
location.href='endofexperiment.php';
}
var startscroll = function(){
count = 0;
flag = 1
if (ie || dom){
scrollerdiv1=dom? first2 : document.getElementById("first2")
scrollerdiv2=dom? second2 : document.getElementById("second2")
move3(scrollerdiv1)
scrollerdiv2.style.right=scrollerwidth
}
else if (document.layers){
document.main.visibility='show'
move1(document.main.document.first)
document.main.document.second.right=parseInt(scrollerwidth)+5
document.main.document.second.visibility='show'
}
document.form.button.disabled=false
}
window.onload=startscroll
</script>
<div align="right"></div>
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}; visibility=hide>
<layer id="first" right=1 top=0 width=&{scrollerwidth}; >
<script language="JavaScript1.2">
flag = 1
if (document.layers)
document.write(slideimages[0])
</script>
</layer>
<layer id="second" right=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
flag = 1
if (document.layers)
document.write(slideimages[1])
</script>
</layer>
</ilayer>
<script language="JavaScript1.2">
flag = 1
if (ie || dom){
document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+'">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);right:0px;top:0px">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';right:1px;top:0px;">')
document.write(slideimages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';right:0px;top:0px">')
document.write(slideimages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</div>')
}
function disp(flag)
{
if(flag == 1){
//var t = document.getElementById('')
if(imgid == 0){
var e = alert("Correct Rejection : No target")
count = count + 1;
popup3()
}
else{
var f = alert("Miss:Oops you missed a knife! ")
count = count + 1;
popup2()
}
}
return 1
}
function disp1()
{
flag = 0
//var p = document.getElementById('myImage')
if(imgid == 0){
var g = alert("False Alarm :Oops, you stopped a bag without a knife!")
count = count + 1;
popup1()
}
else{
var h = alert("Hit :Good Job!")
count = count + 1;
popup()
}
}
</script>
<style>
.btn{border: #80000 solid; width:100px; padding: 2px 8px;}
.btn:hover{border: #80000 solid; width:100px; background-color: #c88889; padding: 2px 8px}
</style>
<body TEXT="000000" BGCOLOR="FFFFFF">
<form name="form">
<center>
<input type="button" value="Stop bag" name="button" onclick="disp1()" />
</center>
</form>
</body>
Thanks,