![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello Say I have a welcome page and 2 other pages, a.htm and b.htm. How can I guide visitors, alternately to a and to b? |
#3
| |||
| |||
|
|
A much simpler method would be a link randomizer. ?php $links = array('a.html','b.html','c.html','d.html'); $last=count($links)-1; $link=$links[rand(0,$last)]; echo "<a href=\"$link\">Mystery Tour</a>"; ? |
#4
| |||
| |||
|
|
?php $links = array('a.html','b.html','c.html','d.html'); $last=count($links)-1; $link=$links[rand(0,$last)]; echo "<a href=\"$link\">Mystery Tour</a>"; ? |
#5
| |||
| |||
|
|
On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little" lws4art (AT) central (DOT) net> wrote: A much simpler method would be a link randomizer. ?php $links = array('a.html','b.html','c.html','d.html'); $last=count($links)-1; $link=$links[rand(0,$last)]; echo "<a href=\"$link\">Mystery Tour</a>"; ? Thanks Joanathan, when I use the above I get Mystery Tour"; ? I must be missing something? |
#6
| |||
| |||
|
|
On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little" lws4art (AT) central (DOT) net> wrote: ?php $links = array('a.html','b.html','c.html','d.html'); $last=count($links)-1; $link=$links[rand(0,$last)]; echo "<a href=\"$link\">Mystery Tour</a>"; ? I didn't save as .php file! Any thoughts on this one? script type="text/javascript" function getNextPage(){ var num = Math.random(); if (num<.5) { location.href="test1/test1.htm"; } else { location.href="test2/test2.htm"; } } /script IMG alt="image" src="assets/images/movelab1.gif" onClick="getNextPage();" The reason for the 2 pages is that this web site will have some music related exercises and we wish to have a kind of control group etc. |
#7
| |||
| |||
|
|
The reason for the 2 pages is that this web site will have some music related exercises and we wish to have a kind of control group etc. And what will happen if the visitor has JavaScript disabled? |
|
The server side solution means it doesn't matter. |
#8
| |||
| |||
|
|
3) attention to the escaped quotes echo "<a href=\"$link\">Mystery Tour</a>"; ^ ^ or concatenate with single quotes echo '<a href="' . $link . '">Mystery Tour</a>'; |
#9
| |||
| |||
|
|
Geoff Cox wrote: On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little" lws4art (AT) central (DOT) net> wrote: A much simpler method would be a link randomizer. ?php $links = array('a.html','b.html','c.html','d.html'); $last=count($links)-1; $link=$links[rand(0,$last)]; echo "<a href=\"$link\">Mystery Tour</a>"; ? Thanks Joanathan, when I use the above I get Mystery Tour"; ? I must be missing something? 1) your server must support php 2) the page is named with a ".php" extension (normally for most server setups) 3) attention to the escaped quotes echo "<a href=\"$link\">Mystery Tour</a>"; ^ ^ or concatenate with single quotes echo '<a href="' . $link . '">Mystery Tour</a>'; |
#10
| |||
| |||
|
|
Or use the safer and more portable printf instead of the deprecated echo: |
|
printf '<a href="%s">Mystery Tour</a>\n' "$link" |
![]() |
| Thread Tools | |
| Display Modes | |
| |