471,310 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

? use smilesImages[0]="smiles/007.gif" in <img id="sigsviewer" src=

Hi All;

I have a few of these;

sigsImages[0]="sigs/finished1.jpg"
sigsImages[1]="sigs/foghorn.jpg"
lower I have;

<td align="center"><img id="sigsviewer" src="sigs/alien.gif"></td>

Can I use sigsImages[0] instead of "sigs/alien.gif"?
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #1
22 2332
Lee
David. E. Goble said:

Hi All;

I have a few of these;

sigsImages[0]="sigs/finished1.jpg"
sigsImages[1]="sigs/foghorn.jpg"
lower I have;

<td align="center"><img id="sigsviewer" src="sigs/alien.gif"></td>

Can I use sigsImages[0] instead of "sigs/alien.gif"?


No. The lines above are Javascript. Those below are HTML.
The syntax looks similar, but you can't mix them.

Jul 23 '05 #2
"Lee" <RE**************@cox.net> wrote in message
news:ct*********@drn.newsguy.com...
David. E. Goble said:

Hi All;

I have a few of these;

sigsImages[0]="sigs/finished1.jpg"
sigsImages[1]="sigs/foghorn.jpg"
lower I have;

<td align="center"><img id="sigsviewer" src="sigs/alien.gif"></td>

Can I use sigsImages[0] instead of "sigs/alien.gif"?


No. The lines above are Javascript. Those below are HTML.
The syntax looks similar, but you can't mix them.


Actually you can but you probably wouldn't want to.

<td align="center">
<script type="text/javascript">
document.write('<img id="sigsviewer" src="' + sigsImages[0] + '">');
</script>
</td>

or

<script type="text/javascript">
document.write('<td align="center"><img id="sigsviewer" src="' +
sigsImages[0] + '"></td>');
</script>

It would only run in JavaScript-enabled browsers.
Jul 23 '05 #3
David. E. Goble wrote:
Hi All;

I have a few of these;

sigsImages[0]="sigs/finished1.jpg"
sigsImages[1]="sigs/foghorn.jpg"
lower I have;

<td align="center"><img id="sigsviewer" src="sigs/alien.gif"></td>

Can I use sigsImages[0] instead of "sigs/alien.gif"?
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


I have the same question, posted just after yours.

Essentially, we are both asking: How can I get all of those ABSOLUTE
REFERENCES out of my HTML, and into some .js or .css file which I can
manipulate them centrally? Right?
Jul 23 '05 #4
>
I have the same question, posted just after yours.

Essentially, we are both asking: How can I get all of those ABSOLUTE
REFERENCES out of my HTML, and into some .js or .css file which I can
manipulate them centrally? Right?


Right! My problem is I need to display a heap of pictures in a folder,
with server side includedes or cgi and I am too lazy to type each and
every1 lol.

However I did have to capture a dir listing into a file and write a c
program to read them in and warp them in htm then thru a program to
convert to js as below;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<SCRIPT src="sigsheader.js"></SCRIPT>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team
Special Forces</h2>
<SCRIPT src="sigsbody.js"></SCRIPT>
<P align="center">Then email it to us at <a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>

//Generated By Easy HTML To Any Script Converter
document.writeln("<script type=\"text/javascript\">");
document.writeln("");
document.writeln("sigsImages=new Array()");
document.writeln("");
document.writeln("sigsImages[0]=\"finished1.jpg\"");
document.writeln("sigsImages[1]=\"foghorn.jpg\"");
document.writeln("sigsImages[2]=\"motto.jpg\"");
document.writeln("sigsImages[3]=\"sig.jpg\"");
document.writeln("sigsImages[4]=\"SWAT.jpg\"");
document.writeln("sigsImages[5]=\"title.gif\"");
document.writeln("");
document.writeln("sigscounter=sigsImages.length-1");
document.writeln("sigsi=0");
document.writeln("");
document.writeln("function sigsfirst()");
document.writeln("{");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[0]");
document.writeln("sigsi=0");
document.writeln("}");
document.writeln("");
document.writeln("function sigsprevious()");
document.writeln("{");
document.writeln("if (sigsi>0)");
document.writeln("{");
document.writeln("sigsi--");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[sigsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function sigsnext()");
document.writeln("{");
document.writeln("if (sigsi<sigscounter)");
document.writeln("{");
document.writeln("sigsi++");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[sigsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function sigslast()");
document.writeln("{");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[sigscounter]");
document.writeln("}");
document.writeln("");
document.writeln("<\/script>");

//Generated By Easy HTML To Any Script Converter
document.writeln("<center>");
document.writeln("<h1>sigs<\/h1>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"sigsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\" onclick=\"sigsprevious()\"
type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"sigsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"sigslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<table border=\"1\">");
document.writeln("<tr>");
document.writeln("<td align=\"center\"><img id=\"sigsviewer\"
src=\"motto.jpg\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<p><\/p>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"sigsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\" onclick=\"sigsprevious()\"
type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"sigsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"sigslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<p><\/p>");
document.writeln("<p>If you have a smilely<\/p>");
document.writeln("<\/center>");

Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #5
It did not seem to work! Here are the three files I have;

//Generated By Easy HTML To Any Script Converter
document.writeln("<script type=\"text/javascript\">");
document.writeln("");
document.writeln("sigsImages=new Array()");
document.writeln("");
document.writeln("sigsImages[0]=\"finished1.jpg\"");
document.writeln("sigsImages[1]=\"foghorn.jpg\"");
document.writeln("sigsImages[2]=\"motto.jpg\"");
document.writeln("sigsImages[3]=\"sig.jpg\"");
document.writeln("sigsImages[4]=\"SWAT.jpg\"");
document.writeln("sigsImages[5]=\"title.gif\"");
document.writeln("");
document.writeln("sigscounter=sigsImages.length-1");
document.writeln("sigsi=0");
document.writeln("");
document.writeln("function sigsfirst()");
document.writeln("{");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[0]");
document.writeln("sigsi=0");
document.writeln("}");
document.writeln("");
document.writeln("function sigsprevious()");
document.writeln("{");
document.writeln("if (sigsi>0)");
document.writeln("{");
document.writeln("sigsi--");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[sigsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function sigsnext()");
document.writeln("{");
document.writeln("if (sigsi<sigscounter)");
document.writeln("{");
document.writeln("sigsi++");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[sigsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function sigslast()");
document.writeln("{");
document.writeln("document.getElementById(\'sigsvi ewer\').src=sigsImages[sigscounter]");
document.writeln("}");
document.writeln("");
document.writeln("<\/script>");

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<SCRIPT src="sigsheader.js"></SCRIPT>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team
Special Forces</h2>
<SCRIPT src="sigsbody.js"></SCRIPT>
<P align="center">Then email it to us at <a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>
//Generated By Easy HTML To Any Script Converter
document.writeln("<center>");
document.writeln("<h1>sigs<\/h1>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"sigsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\" onclick=\"sigsprevious()\"
type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"sigsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"sigslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<table border=\"1\">");
document.writeln("<tr>");
document.writeln("<td align=\"center\"><img id=\"sigsviewer\"
src=\"motto.jpg\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<p><\/p>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"sigsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\" onclick=\"sigsprevious()\"
type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"sigsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"sigslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<p><\/p>");
document.writeln("<p>If you have a smilely<\/p>");
document.writeln("<\/center>");

Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #6
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:hh********************************@4ax.com...
It did not seem to work! Here are the three files I have;


[snip}

Might I suggest this rewrite of our code?

This is little more readable / maintainable.

(I renamed "sigshead.js" from "sigsheader.js" -- I like 8.3 naming.)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript" src="sigshead.js"></script>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team
Special Forces</h2>
<script type="text/javascript" src="sigsbody.js"></script>
<P align="center">Then email it to us at <a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>
var body = [
'<center>',
'<' + 'script type="text/javascript">',
'var sigsImages = new Array()',
' sigsImages[0] = "finished1.jpg"',
' sigsImages[1] = "foghorn.jpg"',
' sigsImages[2] = "motto.jpg"',
' sigsImages[3] = "sig.jpg"',
' sigsImages[4] = "SWAT.jpg"',
' sigsImages[5] = "title.gif"',
'var sigscounter = sigsImages.length-1',
'var sigsi = 0',
'function sigsfirst() {',
' document.getElementById("sigsviewer").src = sigsImages[0]',
' sigsi = 0',
'}',
'function sigsprevious() {',
' if (sigsi>0) {',
' sigsi--',
' document.getElementById("sigsviewer").src = sigsImages[sigsi]',
' }',
'}',
'function sigsnext() {',
' if (sigsi<sigscounter) {',
' sigsi++',
' document.getElementById("sigsviewer").src = sigsImages[sigsi]',
' }',
'}',
'function sigslast() {',
' document.getElementById("sigsviewer").src =
sigsImages[sigscounter]',
'}',
'',
'<' + '/script>'
].join('\n');
document.write(body);
var head = [
'<center>',
'<h1>sigs</h1>',
'<form>',
'<input value="First" onclick="sigsfirst()" type="button">',
'<input value="Previous" onclick="sigsprevious()" type="button">',
'<input value="Next" onclick="sigsnext()" type="button">',
'<input value="Last" onclick="sigslast()" type="button">',
'</form>',
'<table border="1">',
'<tr>',
'<td align="center"><img id="sigsviewer" src="motto.jpg"></td>',
'</tr>',
'</table>',
'<p></p>',
'<form>',
'<input value="First" onclick="sigsfirst()" type="button">',
'<input value="Previous" onclick="sigsprevious()" type="button">',
'<input value="Next" onclick="sigsnext()" type="button">',
'<input value="Last" onclick="sigslast()" type="button">',
'</form>',
'<p></p>',
'<p>If you have a smilely</p>',
].join('\n');
document.write(head);
I haven't look ed at the logic partly because i couldn't find the images.

Do you have a base URL for them?
Jul 23 '05 #7
On Tue, 1 Feb 2005 13:48:10 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
var body = [
'<center>',
'<' + 'script type="text/javascript">',
...
].join('\n');
document.write(body);
Yes that does look better... thanks
I haven't look ed at the logic partly because i couldn't find the images.

Do you have a base URL for them?

http://home.insightbb.com/~bow.foggy/sigs/

Also how can I use (from sigshead.js);

sigsImages[ -- Random Number -- ]

In sigsbody.js, in particular on this line;

'<td align="center"><img id="sigsviewer" src="motto.jpg"></td>',

Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #8
On Wed, 02 Feb 2005 22:55:10 +1030, David. E. Goble
<de*****@gtech.computing> wrote:
On Tue, 1 Feb 2005 13:48:10 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
var body = [
'<center>',
'<' + 'script type="text/javascript">',
...
].join('\n');
document.write(body);

Yes that does look better... thanks


But I just tried it and the buttons don't work.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #9
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:0u********************************@4ax.com...
On Wed, 02 Feb 2005 22:55:10 +1030, David. E. Goble
<de*****@gtech.computing> wrote:
On Tue, 1 Feb 2005 13:48:10 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
var body = [
'<center>',
'<' + 'script type="text/javascript">',
...
].join('\n');
document.write(body);

Yes that does look better... thanks


But I just tried it and the buttons don't work.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


I added the following line after the body tag and it worked for me:

<base href="http://home.insightbb.com/~bow.foggy/sigs/">
Jul 23 '05 #10
On Wed, 2 Feb 2005 07:07:33 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:0u********************************@4ax.com.. .
On Wed, 02 Feb 2005 22:55:10 +1030, David. E. Goble
<de*****@gtech.computing> wrote:
>On Tue, 1 Feb 2005 13:48:10 -0600, "McKirahan" <Ne**@McKirahan.com>
>wrote:
>>var body = [
>> '<center>',
>> '<' + 'script type="text/javascript">',
>> ...
>> ].join('\n');
>>document.write(body);
>>
>Yes that does look better... thanks
>>


But I just tried it and the buttons don't work.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


I added the following line after the body tag and it worked for me:

<base href="http://home.insightbb.com/~bow.foggy/sigs/">

Well I cut n pasted from your post and added the abvoe line to the
main html file, but still the buttons do not work.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #11
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:9o********************************@4ax.com...

[snip]
I added the following line after the body tag and it worked for me:

<base href="http://home.insightbb.com/~bow.foggy/sigs/">

Well I cut n pasted from your post and added the abvoe line to the
main html file, but still the buttons do not work.
Regards David. E. Goble


[snip]

You could post your code but you might try this instead:

<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript">
var pics = new
Array("finished1.jpg","foghorn.jpg","motto.jpg","s ig.jpg","SWAT.jpg","title.
gif");
var pict = 0;
function view(what) {
if (what == "<<") pict = 0;
else if (what == "<") if (pict > 0) pict--;
else if (what == ">") if (pict < pics.length-1) pict++;
else if (what == ">>") pict = pics.length-1;
document.getElementById("sigsviewer").src = pics[pict];
}
</script>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<base href="http://home.insightbb.com/~bow.foggy/sigs/">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team Special
Forces</h2>
<center>
<h1>sigs</h1>
<form>
<input type="button" value="First" style="width:100px"
onclick="view('<<')">
<input type="button" value="Previous" style="width:100px"
onclick="view('<')">
<input type="button" value="Next" style="width:100px"
onclick="view('>')">
<input type="button" value="Last" style="width:100px"
onclick="view('>>')">
</form>
<table border="1">
<tr>
<td align="center"><img id="sigsviewer" src="motto.jpg"></td>
</tr>
</table>
<p></p>
<p></p>
<p>If you have a smilely</p>
<P align="center">Then email it to us at <a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>

"getElementById()" is not supported by all browsers; what are you using?
Jul 23 '05 #12
McKirahan wrote:
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:9o********************************@4ax.com...

[snip]
<--snip-->
document.getElementById("sigsviewer").src = pics[pict];
}
<--snip-->
<td align="center"><img id="sigsviewer" src="motto.jpg"></td>
<--snip-->
"getElementById()" is not supported by all browsers; what are you using?


Then why use it when document.images is widely supported?

<img name="sigsviewer".....>

document.images['sigsviewer'].src=.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #13
"Randy Webb" <Hi************@aol.com> wrote in message
news:k_********************@comcast.com...

[snip]
"getElementById()" is not supported by all browsers; what are you using?


Then why use it when document.images is widely supported?

<img name="sigsviewer".....>

document.images['sigsviewer'].src=.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq


Let's go Randy's way:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript">
var pics = new
Array("finished1.jpg","foghorn.jpg","motto.jpg","s ig.jpg","SWAT.jpg","title.
gif");
var pict = 0;
function view(what) {
if (what == "<<") {
pict = 0;
} else if (what == "<") {
if (pict > 0) pict--;
} else if (what == ">") {
if (pict < pics.length-1) pict++;
} else if (what == ">>") {
pict = pics.length-1;
}
document.images["sigsviewer"].src = pics[pict];
}
</script>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<base href="http://home.insightbb.com/~bow.foggy/sigs/">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team Special
Forces</h2>
<center>
<h1>sigs</h1>
<form>
<input type="button" value="First" style="width:100px"
onclick="view('<<')">
<input type="button" value="Previous" style="width:100px"
onclick="view('<')">
<input type="button" value="Next" style="width:100px"
onclick="view('>')">
<input type="button" value="Last" style="width:100px"
onclick="view('>>')">
</form>
<table border="1">
<tr>
<td align="center"><img id="sigsviewer" src="motto.jpg"></td>
</tr>
</table>
<p></p>
<p></p>
<p>If you have a smilely</p>
<P align="center">Then email it to us at <a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>

ALso, I revised "function view()" as it didn't seen to work!
Jul 23 '05 #14
On Wed, 2 Feb 2005 12:14:41 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:

"getElementById()" is not supported by all browsers; what are you using?

I am using netscape 7.2 and Ie x.whatever...

and your code, still did not work. I have ironed out all but this idea
I wanted to implement. Namely have a random pick of the avialable
pictures from the sigsImages[] array.

Thanks anyway.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #15
On Wed, 2 Feb 2005 16:24:30 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
"Randy Webb" <Hi************@aol.com> wrote in message
news:k_********************@comcast.com...

[snip]
> "getElementById()" is not supported by all browsers; what are you using?


Then why use it when document.images is widely supported?

<img name="sigsviewer".....>

document.images['sigsviewer'].src=.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq


Let's go Randy's way:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript">
var pics = new
Array("finished1.jpg","foghorn.jpg","motto.jpg"," sig.jpg","SWAT.jpg","title.
gif");
var pict = 0;
function view(what) {
if (what == "<<") {
pict = 0;
} else if (what == "<") {
if (pict > 0) pict--;
} else if (what == ">") {
if (pict < pics.length-1) pict++;
} else if (what == ">>") {
pict = pics.length-1;
}
document.images["sigsviewer"].src = pics[pict];
}
</script>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<base href="http://home.insightbb.com/~bow.foggy/sigs/">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team Special
Forces</h2>
<center>
<h1>sigs</h1>
<form>
<input type="button" value="First" style="width:100px"
onclick="view('<<')">
<input type="button" value="Previous" style="width:100px"
onclick="view('<')">
<input type="button" value="Next" style="width:100px"
onclick="view('>')">
<input type="button" value="Last" style="width:100px"
onclick="view('>>')">
</form>
<table border="1">
<tr>
<td align="center"><img id="sigsviewer" src="motto.jpg"></td>
</tr>
</table>
<p></p>
<p></p>
<p>If you have a smilely</p>
<P align="center">Then email it to us at <a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>

ALso, I revised "function view()" as it didn't seen to work!

Again, it the buttons don't seem to work in IE or netscape 7.2.

I am still looking for a way to change this

<td align="center"><img id="sigsviewer" src="motto.jpg"></td>

to something like;

<td align="center">
<img id="sigsviewer" src=pics[<-random number->]></td>

So that every time the page is refresh or visted, the starting picture
is different.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #16
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:ov********************************@4ax.com...
On Wed, 2 Feb 2005 12:14:41 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:

"getElementById()" is not supported by all browsers; what are you using?

I am using netscape 7.2 and Ie x.whatever...

and your code, still did not work. I have ironed out all but this idea
I wanted to implement. Namely have a random pick of the avialable
pictures from the sigsImages[] array.

Thanks anyway.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


Here's a version that randomizes the initial image.

It works (for me) using IE5.5 and FF1.0 but not NS6.2.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript">
var pics = new
Array("finished1.jpg","foghorn.jpg","motto.jpg","s ig.jpg","SWAT.jpg","title.
gif");
var pict = Math.round(Math.random()*(pics.length-1));
function view(what) {
if (what == "<<") {
pict = 0;
} else if (what == "<") {
if (pict > 0) pict--;
} else if (what == ">") {
if (pict < pics.length-1) pict++;
} else if (what == ">>") {
pict = pics.length-1;
}
document.images["sigsviewer"].src = pics[pict];
}
</script>
</head>
<body onload="view('')"
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif">
<base href="http://home.insightbb.com/~bow.foggy/sigs/">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color:red">Team Special Forces</h2>
<center>
<h1>sigs</h1>
<form>
<input type="button" value="First" style="width:100px"
onclick="view('<<')">
<input type="button" value="Previous" style="width:100px"
onclick="view('<')">
<input type="button" value="Next" style="width:100px"
onclick="view('>')">
<input type="button" value="Last" style="width:100px"
onclick="view('>>')">
</form>
<table border="0">
<tr height="200">
<th><img id="sigsviewer" src="" style="border: solid 1px black"></th>
</tr>
</table>
<p>If you have a smilely</p>
<p align="center">Then email it to us at<a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>
Jul 23 '05 #17
On Wed, 2 Feb 2005 20:49:41 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:ov********************************@4ax.com.. .
On Wed, 2 Feb 2005 12:14:41 -0600, "McKirahan" <Ne**@McKirahan.com>
wrote:
>
>"getElementById()" is not supported by all browsers; what are you using?
>

I am using netscape 7.2 and Ie x.whatever...

and your code, still did not work. I have ironed out all but this idea
I wanted to implement. Namely have a random pick of the avialable
pictures from the sigsImages[] array.

Thanks anyway.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


Here's a version that randomizes the initial image.

It works (for me) using IE5.5 and FF1.0 but not NS6.2.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript">
var pics = new
Array("finished1.jpg","foghorn.jpg","motto.jpg"," sig.jpg","SWAT.jpg","title.
gif");
var pict = Math.round(Math.random()*(pics.length-1));
function view(what) {
if (what == "<<") {
pict = 0;
} else if (what == "<") {
if (pict > 0) pict--;
} else if (what == ">") {
if (pict < pics.length-1) pict++;
} else if (what == ">>") {
pict = pics.length-1;
}
document.images["sigsviewer"].src = pics[pict];
}
</script>
</head>
<body onload="view('')"
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif">
<base href="http://home.insightbb.com/~bow.foggy/sigs/">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color:red">Team Special Forces</h2>
<center>
<h1>sigs</h1>
<form>
<input type="button" value="First" style="width:100px"
onclick="view('<<')">
<input type="button" value="Previous" style="width:100px"
onclick="view('<')">
<input type="button" value="Next" style="width:100px"
onclick="view('>')">
<input type="button" value="Last" style="width:100px"
onclick="view('>>')">
</form>
<table border="0">
<tr height="200">
<th><img id="sigsviewer" src="" style="border: solid 1px black"></th>
</tr>
</table>
<p>If you have a smilely</p>
<p align="center">Then email it to us at<a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>

Mmmm that seems to work, if a bit slow... THanks. Any way of speeding
it up?
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #18
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:oa********************************@4ax.com...

[snip]
Mmmm that seems to work, if a bit slow... THanks. Any way of speeding
it up?
Regards David. E. Goble


Have you added any images?
The six you had are pretty small.

Are you running locally?
Are you using a dial-up connection?

The images could be preloaded.

How's the speed when you run it by double-clicking on the filename in
Windows Explorer (presuming you're running Windows)?

Jul 23 '05 #19
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:qJ********************@comcast.com...
"David. E. Goble" <de*****@gtech.computing> wrote in message
news:oa********************************@4ax.com...

[snip]
Mmmm that seems to work, if a bit slow... THanks. Any way of speeding
it up?
Regards David. E. Goble


The images could be preloaded.

Insert the following:

for (var i=0; i<pics.length; i++) {
var picx = new Image();
picx.src = pics[i];
}

immediate above: "function view(what) {"

How's the speed now?
Jul 23 '05 #20
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:i4********************@comcast.com...

[snip]

You might want to add this as the last line in the function:

window.status = "Picture " + (pict+1) + " of " + pics.length;

This will indicate "Picture # of #" on the browser's status bar.

(You may want to change it to "Image # of #".)

This will advise the user:
a) to not press "First" or "Previous" if it's "1 of 1" or
b) to not press "Next" or "Last" if it's "6 of 6".

Another approach would be to disable "invalid" buttons.
Jul 23 '05 #21
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:7o********************@comcast.com...
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:i4********************@comcast.com...

[snip]

Another approach would be to disable "invalid" buttons.


Okay, here's a version with this feature too.

It works in IE and FF but not NS; see
http://www.quirksmode.org/js/cssdisable.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored signatures</title>
<script type="text/javascript">
var pics = new
Array("finished1.jpg","foghorn.jpg","motto.jpg","s ig.jpg","SWAT.jpg","title.
gif");
var pict = Math.round(Math.random()*(pics.length-1));
for (var i=0; i<pics.length; i++) {
var img = new Image();
img.src = pics[i];
}
function view(what) {
if (what == "<<") {
pict = 0;
} else if (what == "<") {
if (pict > 0) pict--;
} else if (what == ">") {
if (pict < pics.length-1) pict++;
} else if (what == ">>") {
pict = pics.length-1;
}
document.images["sigsviewer"].src = pics[pict];
window.status = "Picture " + (pict+1) + " of " + pics.length;
//
document.getElementById("F").disabled = false;
document.getElementById("P").disabled = false;
document.getElementById("N").disabled = false;
document.getElementById("L").disabled = false;
if (pict == 0) {
document.getElementById("F").disabled = true;
document.getElementById("P").disabled = true;
} else if (pict == pics.length-1) {
document.getElementById("N").disabled = true;
document.getElementById("L").disabled = true;
}
}
</script>
</head>
<body onload="view('')"
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif">
<base href="http://home.insightbb.com/~bow.foggy/sigs/">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color:red">Team Special Forces</h2>
<center>
<h1>sigs</h1>
<form>
<input type="button" value="First" id="F" style="width:100px"
onclick="view('<<')">
<input type="button" value="Previous" id="P" style="width:100px"
onclick="view('<')">
<input type="button" value="Next" id="N" style="width:100px"
onclick="view('>')">
<input type="button" value="Last" id="L" style="width:100px"
onclick="view('>>')">
</form>
<table border="0">
<tr height="200">
<th><img id="sigsviewer" src="" style="border: solid 1px black"></th>
</tr>
</table>
<p>If you have a smilely</p>
<p align="center">Then email it to us at<a
href="mailto:Bo*******@insightbb.com">Bo*******@in sightbb.com</a></p>
</body>
</html>
Jul 23 '05 #22

Oh Man, that is sooo cool. Thanks that's exactally what I wanted to do
and a bit more cleaner than my partial solution.
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
Jul 23 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Scott | last post: by
14 posts views Thread by Brandon Hoppe | last post: by
reply views Thread by Martin | last post: by
12 posts views Thread by A.M | last post: by
5 posts views Thread by euronay | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.