As I dive into the world of programming, there's a specific concept that continues to elude me.
In creating a website, I've implemented a button that randomly redirects users to different destinations. However, my goal now is to alternate between two specific destinations - directing one user to page one and the next to page two.
Below is the current script handling the randomization:
<script>
var randomlinks=new Array()
randomlinks[0]="juice.html"
randomlinks[1]="no-juice.html"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
</script>
To trigger this script, I've incorporated the following form element:
<form method="post">
<p><input class = "button button1" type="button" name="B1" value="Start Test >>" onclick="randomlink()"></p>
</form>
If anyone could offer some guidance on achieving my desired outcome, it would be greatly appreciated! Thank you in advance (: