...

View Full Version : Random Goolge Video...



camalex
09-01-2006, 11:34 PM
Basically, I have multiple Google videos... but I only want to display one at a time on my site. So, the best way to do this is have the one displayed to be randomly picked... but I have no clue how to do this.

I do know the embed html is

<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-4203295387902104151&hl=en"></embed>

The bolded part is the part that needs to be either

4203295387902104151
8909400237855893347
1446340990435255030

One of those three numbers. I know I CAN do it, just no clue what I'm doing enough to be able to do it. Help?

mic2100
09-02-2006, 10:37 AM
here this makes a random number and using a switch statement it chooses one of the videos



<script language="javascript" type="text/javascript">
function get_random(n)
{
var ranNum = (Math.floor(Math.random()* n + 1 ) );

var docId

switch(ranNum)
{


case 1:

docId = 4203295387902104151;
break;

case 2:

docId = 8909400237855893347;
break;

case 3:

docId = 1446340990435255030;
break;

}

document.getElementById("VideoPlayback").src = "http://video.google.com/googleplayer.swf?docId=-" + docId + "&hl=en";
}
</script>



<!-- change this number depending on the amount of cases you have in the switch statement (reflects the amount of movies you want to display-->

<body onLoad="get_random(3)">
<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src=""></embed>

</body>

camalex
09-02-2006, 06:25 PM
Uhh, didn't work... Gahh, what's wrong? I'm clueless....

rafiki
09-02-2006, 07:29 PM
the url chosen during the random needs to be saved into a var so u can write the var into the scr in the embed tag



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum