PDA

View Full Version : Basic Syntax Question



JayBlake
07-14-2007, 11:06 AM
I have a length field that works fine in my Javascript program but it's really long and unwieldly. So I tried to assign a short variable name to it but MS IE doesn't like my statement (something about NaN, which I know means "not a number"). Does anyone see anything wrong with coding . . . . .
var tablelen = document.SlideShow.SelectTable.length;
(The length is the total number of entries in a SELECT table)
Thanks.

djr33
07-14-2007, 01:48 PM
Quick guess... is "SlideShow" the name of the slideshow or should you specify it?

Twey
07-14-2007, 02:04 PM
What on Earth is a "SELECT table?" Also, where have you defined document.SlideShow?

jscheuer1
07-14-2007, 03:44 PM
Yes, that is precious little code for us to be able to tell what the trouble is:

Please post a link to the page on your site that contains the problematic script so we can check it out.

JayBlake
07-14-2007, 10:48 PM
John,

I haven't uploaded the code to my Web site yet because it's not quite finished but here are the applicable parts of the code . . .

var photofolder = 'scans/';
var tablelen = (document.SlideShow.SelectTable.length);
function SlideSelected() {
zoomstat = "Zoom In ";
document.SlideShow.ZoomButton.value = zoomstat;
CurrentSlide = document.SlideShow.SelectTable.selectedIndex;
document.images.ImageWindow.src = (photofolder + document.SlideShow.SelectTable[CurrentSlide].value);
Message = 'Page pair ' + (CurrentSlide+1) + ' of ' + document.SlideShow.SelectTable.length;
self.defaultStatus = Message;
}
.
.
.
</script>

</head>
.
.
.
<form name="SlideShow">
<table align=center border="0" cellpadding="0">
<tr>
<td colspan=2><img name="ImageWindow" border=2></td>
</tr>
<tr>
<td align=left>
<input type="button" name="ZoomButton"
value="Zoom In" onClick="Zoom()">
</td>
<td align=left width="62%">
<input type="button" name="Previous"
value="<<Prev" onClick="ShowSlide(-1)">
<SELECT name="SelectTable" onChange="SlideSelected();">
<OPTION value="WIBRFH1976000-001.jpg" selected>Pair 1</OPTION>
<OPTION value="WIBRFH1976002-003.jpg">Pair 2</OPTION>
<OPTION value="WIBRFH1976004-005.jpg">Pair 3</OPTION>
.
.
.
</SELECT>
<input type="button" name="Next"
value="Next>>" onClick="ShowSlide(1)">
</td>

jscheuer1
07-15-2007, 03:34 AM
Now it might be possible for us to figure out. Personally, I would like to see a demo page of the problem though. Without the resources (images and whatever else might go with it) and full 'as is' code and markup, it would require more time than I want to devote.

If someone else spots the problem and suggest a workable fix, disregard this post.

Otherwise, please put up a demo page that exhibits the problem and post a link to it.

JayBlake
07-16-2007, 10:16 AM
I figured out my problem. The var statement was referencing fields it hadn't gotten to yet. So when I moved the statement to my onLoad function, it worked fine. Thanks for looking at it.