Click to See Complete Forum and Search --> : How can Images be of a fixed width using Javascript?


red_of_rby
03-18-2003, 11:00 AM
Hi, I have this script within a Form, that is basically an Image Slideshow. What I am asking is how can I modify this script, so all images in the slideshow are the same width, and can then fill the page how I would like them to?

<script>
var current = 0;

function initArray() {

this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}

var picz = new initArray(
"Boys/jupp01.jpg",
"Boys/jupp02.jpg",
"Boys/jupp03.jpg",
"Boys/jupp04.jpg",
"Boys/jupp05.jpg",
"Boys/jupp06.jpg",
"Boys/jupp07.jpg",
"Boys/jupp08.jpg",
"Boys/jupp09.jpg",
"Boys/jupplisa01.jpg",
"Boys/jupplucy01.jpg",
"Boys/juppkat01.jpg"
);

document.write('<img name="jscriptimg" src="'+picz[0]+'">');

function checkIt(val) {

var goodnum = current+val;

if (goodnum < 0) alert("You can't go any further back!");
else if (goodnum > picz.length-1) alert("You can't go any further forward!");
else document.jscriptimg.src = picz[goodnum];

current = goodnum;
}
</script>

Cheers

Ed

khalidali63
03-18-2003, 11:09 AM
document.write('<img name="jscriptimg" src="'+picz[0]+'" width=400 height=400>');

set the width and height attributes

Cheers

Khalid

Nedals
03-18-2003, 11:36 AM
Remember, this method could distort your images if the height to width ratio changes from the original. It is far better to resize your images prior to using them in your site.