pgo
September 15th, 2003, 09:26 AM
I just got my first problem answered so I thought I'd pose another one.
The following function is called from a main page and displays a picture with some info. I want to have next and previous buttons to show other images i the list. To do this I tried calling the function again when the the 'next image' is pressed but it generates an error. I cannot figure out why.
A seperate problem is that when I try to increment the variable num it treats num like a string and simply concatenates a 1 to the previous number.
Note that the variables n1, h1, w1, and d1 are global variables (arrays).
I would really appreciate any help anyone could give.
Per-Gunnar
-----------
function image_win(gall, num)
{
var img;
var len;
var desc = '';
var next = num + 1;
img = 'images/' +n1[num]+ '.jpg';
gallname = 'graphics/' +gall+ '_name.gif';
len = d1[num].length;
for (a=0;a<len;a++) {
if (d1[num].charAt(a) == '_') desc = desc + ' ';
else desc = desc + d1[num].charAt(a);
}
document.writeln("<HTML>\n<HEAD>\n\t<TITLE>pgo images - if window blank press F5</TITLE>\n");
document.writeln("</HEAD>\n\n<BODY BGCOLOR='#323232' TEXT='#FFFFFF'>");
document.writeln("\t<TABLE BORDER='0' VALIGN='center' WIDTH='100%' HEIGHT='100%'>");
document.writeln("\t\t<TD ALIGN = 'left'>\n\t\t\t<IMG SRC=" +gallname+ " width='250' HEIGHT='26' ALT=''>\n\t\t</TD>");
document.writeln("\t\t<TD ALIGN = 'center' COLSPAN = 2>");
document.writeln("<A HREF=javascript:image_win('" +gall+ "','"+next+"')>next image</A>");
document.writeln("\t\t\t<FONT SIZE='2' FACE='verdana'>" +n1[num]+ " - " +desc);
document.writeln("\t\t\t<BR><BR><CENTER>\n\t\t\t<IMG SRC=" +img+ " NAME='pic' WIDTH=" +w1[num]+ " HEIGHT=" +h1[num]+ " BORDER='30' ALT=''>");
document.writeln("\t\t</TD>\n\t</TABLE>");
document.writeln("</BODY>\n</HTML>")
}
The above code generates the following web page for example.
<HTML>
<HEAD>
<TITLE>pgo images - if window blank press F5</TITLE>
</HEAD>
<BODY BGCOLOR='#323232' TEXT='#FFFFFF'>
<TABLE BORDER='0' VALIGN='center' WIDTH='100%' HEIGHT='100%'>
<TD ALIGN = 'left'>
<IMG SRC=graphics/adin_name.gif width='250' HEIGHT='26' ALT=''>
</TD>
<TD ALIGN = 'center' COLSPAN = 2>
<A HREF=javascript:image_win('adin','5')>next image</A>
<FONT SIZE='2' FACE='verdana'>030830-012 - my test
<BR><BR><CENTER>
<IMG SRC=images/030830-012.jpg NAME='pic' WIDTH=399 HEIGHT=600 BORDER='30' ALT=''>
</TD>
</TABLE>
</BODY>
</HTML>
The following function is called from a main page and displays a picture with some info. I want to have next and previous buttons to show other images i the list. To do this I tried calling the function again when the the 'next image' is pressed but it generates an error. I cannot figure out why.
A seperate problem is that when I try to increment the variable num it treats num like a string and simply concatenates a 1 to the previous number.
Note that the variables n1, h1, w1, and d1 are global variables (arrays).
I would really appreciate any help anyone could give.
Per-Gunnar
-----------
function image_win(gall, num)
{
var img;
var len;
var desc = '';
var next = num + 1;
img = 'images/' +n1[num]+ '.jpg';
gallname = 'graphics/' +gall+ '_name.gif';
len = d1[num].length;
for (a=0;a<len;a++) {
if (d1[num].charAt(a) == '_') desc = desc + ' ';
else desc = desc + d1[num].charAt(a);
}
document.writeln("<HTML>\n<HEAD>\n\t<TITLE>pgo images - if window blank press F5</TITLE>\n");
document.writeln("</HEAD>\n\n<BODY BGCOLOR='#323232' TEXT='#FFFFFF'>");
document.writeln("\t<TABLE BORDER='0' VALIGN='center' WIDTH='100%' HEIGHT='100%'>");
document.writeln("\t\t<TD ALIGN = 'left'>\n\t\t\t<IMG SRC=" +gallname+ " width='250' HEIGHT='26' ALT=''>\n\t\t</TD>");
document.writeln("\t\t<TD ALIGN = 'center' COLSPAN = 2>");
document.writeln("<A HREF=javascript:image_win('" +gall+ "','"+next+"')>next image</A>");
document.writeln("\t\t\t<FONT SIZE='2' FACE='verdana'>" +n1[num]+ " - " +desc);
document.writeln("\t\t\t<BR><BR><CENTER>\n\t\t\t<IMG SRC=" +img+ " NAME='pic' WIDTH=" +w1[num]+ " HEIGHT=" +h1[num]+ " BORDER='30' ALT=''>");
document.writeln("\t\t</TD>\n\t</TABLE>");
document.writeln("</BODY>\n</HTML>")
}
The above code generates the following web page for example.
<HTML>
<HEAD>
<TITLE>pgo images - if window blank press F5</TITLE>
</HEAD>
<BODY BGCOLOR='#323232' TEXT='#FFFFFF'>
<TABLE BORDER='0' VALIGN='center' WIDTH='100%' HEIGHT='100%'>
<TD ALIGN = 'left'>
<IMG SRC=graphics/adin_name.gif width='250' HEIGHT='26' ALT=''>
</TD>
<TD ALIGN = 'center' COLSPAN = 2>
<A HREF=javascript:image_win('adin','5')>next image</A>
<FONT SIZE='2' FACE='verdana'>030830-012 - my test
<BR><BR><CENTER>
<IMG SRC=images/030830-012.jpg NAME='pic' WIDTH=399 HEIGHT=600 BORDER='30' ALT=''>
</TD>
</TABLE>
</BODY>
</HTML>