Jump to content

Beating my head again


Jarod_C

Recommended Posts

I'm trying to set up a random link for ads, and I can't seem to figure any of it out. :) especially if I try if else if else, but I think that's the mathThe problem is getting an image link into a if else, because of " 'quotes' " Example can I "quote 'inside a ?quote? inside' a quote"P.S. If I'm way off it's ok to laugh. :)Here's what I've got minus links being changed. I don't know I'm getting tired, or I ###### at Javascript because it's new to me.

<script type="text/javascript">var r=Math.random()if (r<0.6){document.write("<a href='http://www.w3schools.com/downloadwww.htm'><img src='http://i190.photobucket.com/albums/z179/jarod_c/avatar.gif'></a>")}else if (r>=0.3 && r<0.6){document.write("<a href='http://www.w3schools.com/downloadwww.htm'><img src='http://i190.photobucket.com/albums/z179/jarod_c/avatar.gif'></a>")}else (r>0.3){document.write("<a href='http://www.w3schools.com/downloadwww.htm'><img src='http://i190.photobucket.com/albums/z179/jarod_c/avatar.gif'></a>")}</script>

Or, could anyone possibly write it for me? :) it's ok to say no

Link to comment
Share on other sites

Everything is right there except for else (r>0.3) which should be else if (r>0.3) or just else, but the links will never change because the either the first condition is met, or none of the conditions are met :) . Oh, and you need to excape the newlines in the document.write statements

<script type="text/javascript">var r=Math.random()if (r >= 0.6){document.write("<a href='http://www.w3schools.com/downloadwww.htm'>\<img src='http://i190.photobucket.com/albums/z179/jarod_c/avatar.gif'></a>")}else if (r>=0.3){document.write("<a href='http://www.w3schools.com/downloadwww.htm'>\<img src='http://i190.photobucket.com/albums/z179/jarod_c/avatar.gif'></a>")}else{document.write("<a href='http://www.w3schools.com/downloadwww.htm'>\<img src='http://i190.photobucket.com/albums/z179/jarod_c/avatar.gif'></a>")}</script>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...