james438
12-02-2009, 05:54 AM
<form name="editform" action="#">
<img id="img" src="" style="width:250px;" alt="">
<button onclick="newi1();return false;">prev</button>
<button onclick="newi2();return false;">original image</button>
<button onclick="newi() ;return false;">next</button>
<br><br>
Image File:
<br><input type="text" name="outputtext">
</form>
<script type="text/javascript">
function newi(){
if(newi.Num > newi.ar.length - 1){
newi.Num = 0;
newi.img.src = '/images/screenshots/' + newi.ar[newi.Num];
}
else{
newi.img.src = '/images/screenshots/' + newi.ar[newi.Num];
}
newi.output.value = newi.ar[newi.Num];++newi.Num;return false;
}
function newi1(){--newi.Num;
if(newi.Num < 0 ){newi.Num = newi.ar.length - 1;}
newi.img.src = 'images/screenshots/' + newi.ar[newi.Num];
newi.output.value = newi.ar[newi.Num];return false;
}
function newi2(){
newi.Num = 0;
newi.img.src = 'images/screenshots/' + newi.ar[newi.Num];
newi.output.value = newi.ar[newi.Num];return false;
}
newi.Num = 0;
newi.ar = new Array(ggit1.jpg,ggit2.jpg,ggit3.jpg,ggit4.jpg,ggit5.jpg);
newi.img = document.getElementById('img');
newi.output = document.forms.editform.elements.outputtext;
newi();
</script>
First question: why does the error listed above where the parts of the array are not placed in single quotes cause the buttons to go to an url?
Second question: when the parts of the array are placed in single quotes everything is fine, but why is it that sometimes you have to push a button twice to get an action? Try pushing the buttons in different orders and you will see what I mean. The only button that always works with only one click is the middle button. http://www.animeviews.com/test/test26.php
<img id="img" src="" style="width:250px;" alt="">
<button onclick="newi1();return false;">prev</button>
<button onclick="newi2();return false;">original image</button>
<button onclick="newi() ;return false;">next</button>
<br><br>
Image File:
<br><input type="text" name="outputtext">
</form>
<script type="text/javascript">
function newi(){
if(newi.Num > newi.ar.length - 1){
newi.Num = 0;
newi.img.src = '/images/screenshots/' + newi.ar[newi.Num];
}
else{
newi.img.src = '/images/screenshots/' + newi.ar[newi.Num];
}
newi.output.value = newi.ar[newi.Num];++newi.Num;return false;
}
function newi1(){--newi.Num;
if(newi.Num < 0 ){newi.Num = newi.ar.length - 1;}
newi.img.src = 'images/screenshots/' + newi.ar[newi.Num];
newi.output.value = newi.ar[newi.Num];return false;
}
function newi2(){
newi.Num = 0;
newi.img.src = 'images/screenshots/' + newi.ar[newi.Num];
newi.output.value = newi.ar[newi.Num];return false;
}
newi.Num = 0;
newi.ar = new Array(ggit1.jpg,ggit2.jpg,ggit3.jpg,ggit4.jpg,ggit5.jpg);
newi.img = document.getElementById('img');
newi.output = document.forms.editform.elements.outputtext;
newi();
</script>
First question: why does the error listed above where the parts of the array are not placed in single quotes cause the buttons to go to an url?
Second question: when the parts of the array are placed in single quotes everything is fine, but why is it that sometimes you have to push a button twice to get an action? Try pushing the buttons in different orders and you will see what I mean. The only button that always works with only one click is the middle button. http://www.animeviews.com/test/test26.php