Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error - can't see where though :/

Status
Not open for further replies.

youradds

Programmer
Joined
Jun 27, 2001
Messages
817
Location
GB
Hi,

As you've prob noticied, I'm not a javascript guru ;)

I managed to put this together, based on some code I found on this forum, and my (little) bit of JS knowledge.

Code:
<script type="text/javascript" language="Javascript">
 var maxSize = 400;
function getImg(src){
 var oImg = new Image();
 oImg.src = src;
 var proportion = ( oImg.width > oImg.height ? oImg.width / maxSize : oImg.height / maxSize );
 if (oImg.width <400) {
 document.write('<img src="'+src+'">');
 } elsif (oImg.height <3) {
 document.write('<img src="'+src+'" width="25">');
 } else  {
 var newHeight = oImg.height / proportion;
 var newWidth = oImg.width / proportion;
 document.write('<img src="'+src+'" width="'+newWidth+'" height="'+newHeight+'">');
 }
}
</script>


However, this gives an error :(

Error: missing ; before statement
Source File: Line: 30, Column: 26
Source Code:
} elsif (oImg.height <3) {

It seems to be due to this part;

Code:
 if (oImg.width <400) {
 document.write('<img src="'+src+'">');
 } elsif (oImg.height < 3) {
 document.write('<img src="'+src+'" width="25">');
 } else  {

Can anyone see my (most likely, obvious =)) boo boo?

NB: I'm from a perl background, so appologies if my mistake is a really simple one (i.e is elsif valid in JS? I know it is in Perl, but PHP using elsif .. which gets confusing sometimes <G>)

TIA!

Andy
 
Doh, found the error =)

elsif isn't valid =) Nor is elseif. For anyone reading this, its

} else if (cond)

format :)

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top