All,
I have an external JavaScript code - which basicially has
functionality so that different images are shown when a next or previous button is selected.
What I need to do and know is how to pass the value of the image to the querystring as I need
to use it further. Also I need the remote_sill value in the querystring to have
the default value of image_sill as such in the querystring upon first load.
So the external JavaScript is called like this in the page:
<script type="text/javascript" src="nextPrevious.js"></script>
In the HTML - of the previous and next buttons - I tried to pass the value as such with no luck:
<a href="#" onclick="prev()?remote_sill='+document.imgSrcOrig.src';"><img src="back.jpg" border="0" /></a>
<a href="#" onclick="next()?remote_sill='+document.imgSrcOrig.src';"><img src="next.jpg" border="0" /></a>
Here is the full nextPrevious.js code:
// List image names without extension
var myImg = new Array(4)
myImg[0] = "image_sill";
myImg[1] = "sill_image";
myImg[2] = "image_sill";
myImg[3] = "shape_3_still";
myImg[4] = "shape_sill";
// Tell browser where to find the image
myImgSrc = "sills/";
// Tell browser the type of file
myImgEnd = ".png"
var i = 0;
// Create function to load image
function loadImg() {
document.imgSrcOrig.src = myImgSrc + myImg[i] + myImgEnd;
}
// Create link function to switch image backward
function prev() {
if (i < 1) {
var l = i
} else {
var l = i -= 1;
}
document.imgSrcOrig.src = myImgSrc + myImg[l] + myImgEnd;
}
// Create link function to switch image forward
function next() {
if (i > 2) {
var l = i
} else {
var l = i += 1;
}
document.imgSrcOrig.src = myImgSrc + myImg[l] + myImgEnd;
}
// Load function after page loads
window.onload = loadImg;