2

I found this javascript random text generator from list

var quotes=new Array();
quotes[0] = "text1";
quotes[1] = "Text2";
quotes[2] = "text3";
quotes[3] = "text4";

var q = quotes.length;
var whichquote=Math.round(Math.random()*(q-1));
function showquote(){document.write(quotes[whichquote]);}
showquote();

And html:

<script language="javascript" type="text/javascript" src="quotes.js"></script>

So, it works perfectly, BUT... I want that every text that is generated have specified url, like <a href="#">

Thanks!

1 Answer 1

1

As far as I could get what you need, this might do the job:

function showquote(){document.write('<a href="#">' + quotes[whichquote] + '</a>');}
Sign up to request clarification or add additional context in comments.

6 Comments

Awesome, and it works. But i want that every text have its own url? Thank you very much!
Where should it lead to?
Let's say #1 #2 #3 etc.
If you want, you can see what i exactly want to do: stefan-page.com/tutorijali/3 (fixed in bottom-left corner), Translate: "Also see:".
Stefan, I don't see your example on that page for some reason.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.