0

What I am trying to do is a prize page that comes up every XX pages surfed. The new page would consist of three muscle cars that the user would click on their choice (hood is down). Choice would appear with hood up, showing engine which would have a changeable by admin prize in a space on the air cleaner of the engine (would be a point prize).

I will furnish graphics.
Best Regards,
Curt Bridges

Java Code Here:

doc = document;
function init()
{
// set up objects
stob = doc.forms["teaser"].stayer;
rob = doc.forms["teaser"].randomer;
swob = doc.forms["teaser"].switcher;
}
function proveIt()
{
// create/clear out array
doors = new Array(false,false,false);
// reset tallies
stwin = 0;
stloss = 0;
rwin = 0;
rloss = 0;
swwin = 0;
swloss = 0;
// clear out textareas
stob.value = "";
rob.value = "";
swob.value = "";
// loop through 100 times
for (l=100;l>0;l--)
{
// decide which door holds the prize
d = rand(3);
doors[d] = true;
// randomly pick a door
p = rand(3);
// randomly remove one of the loser doors
removed = false;
while (!removed)
{
r = rand(3);
if (r != d && r != p)
{
removedvalue = r;
removed = true;
}
}
// for randomer, randomly switch/stay
ss = rand(2);
if (ss==0)
{
// switch
switchstay = false;
while (!switchstay)
{
s1 = rand(3);
if (s1 != p && s1 != removedvalue)
{
switchstayvalue = s1;
switchstay = true;
}
}
}
else
{
// stay
switchstayvalue = p;
}
// for switcher, switch
for (s2=0;s2<3;s2++)
{
if (s2 != p && s2 != removedvalue)
{
switchervalue = s2;
switcher = true;
break;
}
}
// determine outcomes
// stayer
if (d==p)
{
stwin++;
stob.value = stwin + " Winner\n" + stob.value;
}
else
{
stloss++;
stob.value = stloss + " Loser\n" + stob.value;
}
// randomer
if (d==switchstayvalue)
{
rwin++;
rob.value = rwin + " Winner\n" + rob.value;
}
else
{
rloss++;
rob.value = rloss + " Loser\n" + rob.value;
}
// switcher
if (d==switchervalue)
{
swwin++;
swob.value = swwin + " Winner\n" + swob.value;
}
else
{
swloss++;
swob.value = swloss + " Loser\n" + swob.value;
}
}
// write final tallies
stob.value = stwin + " winners\n" + stloss + " losses" + "\n-----\n" + stob.value;
rob.value = rwin + " winners\n" + rloss + " losses" + "\n-----\n" + rob.value;
swob.value = swwin + " winners\n" + swloss + " losses" + "\n-----\n" + swob.value;
}
// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See: http://www.msc.cornell.edu/~houle/Ja...andomizer.html
// Usage: rand(n) returns random integer between 0 and n-1
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)-1;
}
</script> 
2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by wheels031799
0

How it does not work? One thing I can tell you right now is that your variables stob, rob, and swop should be declared with var outside any function.

PS: I tested the script and it ran. Not sure what the result you are looking for though. By the way, I had to indent the script in order to read it through.

0

Many ThanksTaywin. Could you please show me where in the code these URLs would go for the graphics to work?

//choice #1 constant
<img src="http://www.classicmusclecars.com/images/showroom/2376_full.jpg" border="0" width="166" height="125"></p>
// prize #1 constant
<p>
<img src="http://www.classicmusclecars.com/images/showroom/2376_3.jpg" border="0" width="166" height="125"></p>
//choice #2 constant
<p>
<img src="http://www.classicmusclecars.com/images/showroom/1982_full.jpg" border="0" width="167" height="125"></p>
// prize #2 constant
<p>
<img src="http://www.classicmusclecars.com/images/showroom/1982_2.jpg" border="0" width="166" height="125"></p>

//choice #3 constant<p>
<img src="http://www.classicmusclecars.com/images/showroom/2137_full.jpg" border="0" width="175" height="118"></p>
<p>
// prize #3 constant
<img src="http://www.classicmusclecars.com/images/showroom/2137_1.jpg" border="0" width="163" height="121"></p>

Edited by Dani: Formatting fixed

0

I have no idea what you mean by adding these images into? Working on Javascript is not only the script itself but it also relates to where to place inside the display (body tag) as well. I can't really tell you exactly unless I see the HTML portion where your script is supposed to manipulate.

0

Thanks

<p>//choice #1 constant<br>
<img src="<a href="http://www.classicmusclecars.com/images/showroom/2376_full.jpg" rel="nofollow">http://www.classicmusclecars.com/images/showroom/2376_full.jpg</a>" border="0" width="166" height="125"></p><br>
// prize #1 constant<br>
<p><br>
<img src="<a href="http://www.classicmusclecars.com/images/showroom/2376_3.jpg" rel="nofollow">http://www.classicmusclecars.com/images/showroom/2376_3.jpg</a>" border="0" width="166" height="125"></p><br>
//choice #2 constant<br>
<p><br>
<img src="<a href="http://www.classicmusclecars.com/images/showroom/1982_full.jpg" rel="nofollow">http://www.classicmusclecars.com/images/showroom/1982_full.jpg</a>" border="0" width="167" height="125"></p><br>
// prize #2 constant<br>
<p><br>
<img src="<a href="http://www.classicmusclecars.com/images/showroom/1982_2.jpg" rel="nofollow">http://www.classicmusclecars.com/images/showroom/1982_2.jpg</a>" border="0" width="166" height="125"></p></p> <p>//choice #3 constant<p><br>
<img src="<a href="http://www.classicmusclecars.com/images/showroom/2137_full.jpg" rel="nofollow">http://www.classicmusclecars.com/images/showroom/2137_full.jpg</a>" border="0" width="175" height="118"></p><br>
<p><br>
// prize #3 constant<br>
<img src="<a href="http://www.classicmusclecars.com/images/showroom/2137_1.jpg" rel="nofollow">http://www.classicmusclecars.com/images/showroom/2137_1.jpg</a></p>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//graffic above

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>function init()<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// set up objects<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stob =
doc.forms["teaser"].stayer;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rob =
doc.forms["teaser"].randomer;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swob =
doc.forms["teaser"].switcher;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>function proveIt()<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// create/clear
out array<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>doors = new
Array(false,false,false);<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// reset tallies<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stwin = 0;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stloss = 0;<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rwin = 0;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rloss = 0;<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swwin = 0;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swloss = 0;<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// clear out
textareas<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stob.value =
"";<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rob.value =
"";<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swob.value =
"";<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// loop through
100 times<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>for
(l=100;l>0;l--)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// decide which
door holds the prize<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>d = rand(3);<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>doors[d] = true;<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// randomly pick a
door<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>p = rand(3);<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// randomly remove
one of the loser doors<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>removed = false;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>while (!removed)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>r = rand(3);<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if (r != d
&& r != p)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>removedvalue = r;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>removed = true;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// for randomer,
randomly switch/stay<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>ss = rand(2);<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if (ss==0)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// switch<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>switchstay =
false;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>while
(!switchstay)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>s1 = rand(3);<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if (s1 != p
&& s1 != removedvalue)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>switchstayvalue =
s1;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>switchstay = true;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>else<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// stay<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>switchstayvalue =
p;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// for switcher,
switch<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>for
(s2=0;s2<3;s2++)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if (s2 != p
&& s2 != removedvalue)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>switchervalue =
s2;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>switcher = true;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>break;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// determine
outcomes<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// stayer<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if (d==p)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stwin++;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stob.value = stwin
+ " Winner\n" + stob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>else<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stloss++;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stob.value =
stloss + " Loser\n" + stob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// randomer<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if
(d==switchstayvalue)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rwin++;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rob.value = rwin +
" Winner\n" + rob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>else<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rloss++;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rob.value = rloss
+ " Loser\n" + rob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// switcher<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>if (d==switchervalue)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swwin++;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swob.value = swwin
+ " Winner\n" + swob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>else<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swloss++;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swob.value =
swloss + " Loser\n" + swob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// write final
tallies<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>stob.value = stwin
+ " winners\n" + stloss + " losses" + "\n-----\n"
+ stob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rob.value = rwin +
" winners\n" + rloss + " losses" + "\n-----\n" +
rob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>swob.value = swwin
+ " winners\n" + swloss + " losses" + "\n-----\n"
+ swob.value;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span><o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>// Usage: rand(n)
returns random integer between 0 and n-1<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rnd.today = new
Date();<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rnd.seed =
rnd.today.getTime();<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>function rnd()<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>rnd.seed =
(rnd.seed*9301+49297) % 233280;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>return
rnd.seed/(233280.0);<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>function
rand(number)<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>return
Math.ceil(rnd()*number)-1;<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></p>

<p class=MsoNormal><span style='mso-spacerun:yes'>    </span></script> <o:p></o:p></p>

<p class=MsoNormal>]<o:p></o:p></p>

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.