Link based on a variable

32 views
Skip to first unread message

m

unread,
Apr 28, 2011, 9:55:13 AM4/28/11
to Google Breadcrumb Developers
I am having a problem getting a link to work- what I want to do is
have the link go to a random page. I have some javascript that will
generate a random number & store it in the variable whichChoice. All I
seem to be able to do is pass this to the next page and display it as
text (see below). But what I want to be able to do is have a link
based on that random number, something like [Take me to a random page]
(<whichChoice>) but I can't get the formatting to work. I tried a
bunch of different combinations- quotes, brackets... keep getting
errors... how do I get a link using the value of whichChoice, not
literally 'whichChoice'

(1) This is page 1
<script>
function get_random()
{
var ranNum= Math.floor(Math.random()*5);
return ranNum;
}
var whichChoice = get_random();
</script>
[Go to page 2](2: whichChoice)
(2)This is page 2 <%= whichChoice %> [Go Back](1)

(3)This is page 3

(4)This is page 4

(5)This is page 5
Message has been deleted

m

unread,
Jun 3, 2011, 12:47:44 PM6/3/11
to Google Breadcrumb Developers
I solved this using the command javascript:go(whichChoice)

laut

unread,
Jun 16, 2011, 11:08:02 PM6/16/11
to Google Breadcrumb Developers
Could I see your app? What you did sounds interesting.

神秘小子

unread,
Jun 19, 2011, 6:44:55 AM6/19/11
to google-brea...@googlegroups.com
sorry,i don't have app.But i like program.

2011/6/17 laut <timoth...@gmail.com>
Reply all
Reply to author
Forward
0 new messages