Random Link Generation - 300 FP for solve

Justin

Legendary Typer
Joined
Jul 2, 2009
Messages
13,882
Reaction score
1
FP$
106
Ok, I have a link in my header nav bar, how do I fix it to where, upon refresh, it shows a new link each time? I need the HTML. If it works, I will pay you 300 fp and rep.

I need it HTML and at least 5 spots to add links, unless it can be unlimited with code.
 
Ok, I am confused.

Let me just say what I need first, I have link in html form on my site. Though I want it to change the ALT text of the link and the link itself.

Does this do this? And is there a way to do it without <form> tags? I want it to work in my nav bar.
 
Put the following between your <head> </head>
Code:
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function go_to(url) {
window.location=url;
}
function rand_link() {
var a;
a = 1 Math.round(Math.random()*3);   // a = random number between 1-3
if (a==1) go_to("http://MYFIRSTLINK.com");
if (a==2) go_to("http://MYSECONDLINK.com");
if (a==3) go_to("http://and.ofcourseMYTHIRDLINK.com");
}
// End -->
</SCRIPT>
Code:
if (a==1) go_to("http://MYFIRSTLINK.com");
if (a==2) go_to("http://MYSECONDLINK.com");
if (a==3) go_to("http://MYTHIRDLINK");
if (a==4) go_to("http://additional.MYFOURTHLINK");
That is where you add/edit your links.

Now, this is going to replace the link on your navbar
Code:
<a href="#" name="mybutton" onClick="rand_link()">Random Link</a>
You can of course change "Random Link" to whatever you like. 🙂

Here is it at live at work: http://edgedhost.com/rlinks.html

***It's exactly what Kirisute posted, I just broke it down/explained it to you the way you wanted it.
 
Ok, sorry, I am a complete idiot with coding and stuff.

Thank you ryan. I will split up 150 FP between you two. Thanks so much.

EDIT: Hmm, I added it, except now, the URL just goes to index.php# so it stays on the index. I changed the links too.

Also, where do I put the second box code? I just put in the first and third code boxes.
 
Would you mind sending me a link to the site/forum via PM? I can't really tell you what you are doing wrong/if you are doing something wrong. 😉

EDIT: NVM

You didn't close one of the tags..
Code:
    if (a==2) go_to("http://www.forumadvertising.org/viewforum.php?f=48

It should be
Code:
    if (a==2) go_to("http://www.forumadvertising.org/viewforum.php?f=48");
 
For some reason, the code posted didn't show the plus sign..

Code:
a = 1[put a plus sign here]Math.round(Math.random()*3);   // a = random number between 1-3

without the [] ofcourse
 
I only edited the links.

That didn't work either.
EDIT: Checking
 
Sorry, didn't know plus sign was banned or something :/.

Edited prior post.
 
Back
Top Bottom