View Full Version : Random Goolge Video...

09-02-2006, 12:34 AM
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


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?

09-02-2006, 11: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


case 1:

docId = 4203295387902104151;

case 2:

docId = 8909400237855893347;

case 3:

docId = 1446340990435255030;


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

<!-- 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>


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

09-02-2006, 08: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