morse
February 23, 2003, 10:44am
1
<SCRIPT language="Javascript">
<!--
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
return Math.ceil(rnd()*number);
};
// end central randomizer. -->
</SCRIPT>
<SCRIPT language="Javascript">
<!--
picnum = rand(4);
if (picnum==1) {img="http://www.morsedesigns.com//bigk/1.gif"; url="http://www.morsedesigns.com"; }
else if (picnum==2) {img="http://www.morsedesigns.com//bigk/2.gif"; url="http://www.morsedesigns.com"; }
else if (picnum==3) {img="http://www.morsedesigns.com//bigk/3.gif"; url="http://www.morsedesigns.com"; }
else {img="http://www.morsedesigns.com//bigk/4.gif"; url="http://www.morsedesigns.com"; }
document.write('<a href="'+url+'"><img src="'+img+'"></a>');
// -->
</SCRIPT>
help ^ no work
system
February 23, 2003, 10:50am
2
Curious why you don’t see what’s in the tag… Hm… Strange…
*Originally posted by morse *
**
<SCRIPT language="Javascript">
<!--
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
return Math.ceil(rnd()*number);
};
// end central randomizer. -->
</SCRIPT>
<SCRIPT language="Javascript">
<!--
picnum = rand(4);
if (picnum==1) {img="http://www.morsedesigns.com//bigk/1.gif"; url="http://www.morsedesigns.com"; }
else if (picnum==2) {img="http://www.morsedesigns.com//bigk/2.gif"; url="http://www.morsedesigns.com"; }
else if (picnum==3) {img="http://www.morsedesigns.com//bigk/3.gif"; url="http://www.morsedesigns.com"; }
else {img="http://www.morsedesigns.com//bigk/4.gif"; url="http://www.morsedesigns.com"; }
document.write('<a href="'+url+'"><img src="'+img+'"></a>');
// -->
</SCRIPT>
<SCRIPT language="Javascript">
<!--
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
return Math.ceil(rnd()*number);
};
// end central randomizer. -->
</SCRIPT>
<SCRIPT language="Javascript">
<!--
picnum = rand(4);
if (picnum==1) {img="http://www.morsedesigns.com//bigk/1.gif"; url="http://www.morsedesigns.com"; }
else if (picnum==2) {img="http://www.morsedesigns.com//bigk/2.gif"; url="http://www.morsedesigns.com"; }
else if (picnum==3) {img="http://www.morsedesigns.com//bigk/3.gif"; url="http://www.morsedesigns.com"; }
else {img="http://www.morsedesigns.com//bigk/4.gif"; url="http://www.morsedesigns.com"; }
document.write('<a href="'+url+'"><img src="'+img+'"></a>');
// -->
</SCRIPT>
**
system
February 23, 2003, 10:52am
3
eh? when i posted with code brackets it didnt work, but i changed to php if that is what you mean.
system
February 23, 2003, 6:11pm
4
Why don’t you store the images in array and choose randomly from that array?
system
February 23, 2003, 9:12pm
5
Like this? Something is wrong… I suck too much to figure out what…
<SCRIPT LANGUAGE="JAVASCRIPT">
var img_rnd = new Array ("1.gif", "2.gif", "3.gif", "4.gif", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.gif", "11.gif", "12.gif");
var i = Math.round(Math.random() * 11);
document.write('<a href="http://www.morsedesigns.com" target="_new"> <IMG SRC="www.morsedesigns.com//bigk/' + img_rnd*>');
</SCRIPT>
system
February 23, 2003, 9:49pm
6
What about this??? You had non matching quotes problem… I do see the random file names with the alert() after I fixed that problem…
<SCRIPT LANGUAGE="JAVASCRIPT">
var img_rnd = new Array ("1.gif", "2.gif", "3.gif", "4.gif", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.gif", "11.gif", "12.gif");
var i = Math.round(Math.random() * 11);
alert(img_rnd*);
document.write('<a href="http://www.morsedesigns.com" target="_new"> <IMG SRC="www.morsedesigns.com//bigk/" + img_rnd*>');
</SCRIPT>
system
February 23, 2003, 10:07pm
7
<SCRIPT LANGUAGE="JAVASCRIPT">
var img_rnd = new Array ("1.gif", "2.gif", "3.gif", "4.gif", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.gif", "11.gif", "12.gif");
var i = Math.round(Math.random() * 11);
alert(img_rnd*);
document.write('<a href="http://www.morsedesigns.com" target="_new"> <IMG SRC="www.morsedesigns.com//bigk/" + img_rnd*>');
</SCRIPT>
[edit by lostinbeta]forgot the php tags ;)[/edit]
system
February 23, 2003, 10:53pm
8
Still unmatching quotes…
<SCRIPT LANGUAGE="JAVASCRIPT">
var img_rnd = new Array ("1.gif", "2.gif", "3.gif", "4.gif", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.gif", "11.gif", "12.gif");
var i = Math.round(Math.random() * 11);
alert(img_rnd*);
document.write("<a href='http://www.morsedesigns.com' target='_blank'> <IMG SRC='www.morsedesigns.com/bigk/'" + img_rnd*+">");
</SCRIPT>
Also you had the target as _new it should be _blank and your moredesigns.com//bigk should only be one forward slash.
system
February 23, 2003, 11:13pm
10
And while I am at it, I made some slight adjustments…
<SCRIPT LANGUAGE="JAVASCRIPT">
var img_rnd =
["1.gif",
"2.gif",
"3.gif",
"4.gif",
"5.gif",
"6.gif",
"7.gif",
"8.gif",
"9.gif",
"10.gif",
"11.gif",
"12.gif"]
var i = Math.floor(Math.random()*img_rnd.length);
alert(img_rnd*);
document.write("<a href='http://www.morsedesigns.com' target='_blank'> <IMG SRC='http://www.morsedesigns.com/bigk/'" + img_rnd* + ">");
</SCRIPT>
I lined the array up like that just because it makes it easier to read and edit then when it is one really long line.
Then I changed the i variable to be a more efficient equation that uses Math.floor bceause arrays start counting at 0, and with Math.round() it is very rare if at all you will get 1.gif in that case. I also multiplied the random number by the length of the img_rnd array so that you won’t have to update this equation when you update the array.
I didn’t test it, but it should work.
system
February 23, 2003, 11:31pm
11
Wait Wait… I got a chance to test it, that script doesn’t work, I got the quotation wrong (I knew I shoulda tested it!)
<SCRIPT LANGUAGE="JAVASCRIPT">
var img_rnd =
["1.gif",
"2.gif",
"3.gif",
"4.gif",
"5.gif",
"6.gif",
"7.gif",
"8.gif",
"9.gif",
"10.gif",
"11.gif",
"12.gif"]
var i = Math.floor(Math.random()*img_rnd.length);
var addImage = img_rnd*;
alert(addImage);
document.write("<a href='http://www.morsedesigns.com' target='_blank'> <IMG SRC=http://www.morsedesigns.com/bigk/" + addImage + "></A>");
</SCRIPT>
Works great.
I added a variable for img_rnd* because you use it twice, so for easier updating if ever necessary you can just edit that. I also forgot to close the A tag.
system
February 24, 2003, 2:05am
12
Wow Shane thanks man =) Your good at this. Yes, you are. Thanks again man. I know nothing about JS.
And CyanBlue, thanks also!
system
February 24, 2003, 4:08am
13
No problem man… JS was my thing before AS as you know