/    Sign up×
Community /Pin to ProfileBookmark

Help with passing variable to function?

Hi Guys,
i have some code to grab all the latest videos from a youtube user, and then display 1 video embedded, and the rest of the videos are thumbnails below the main video.

I would like to have it so when the thumbnails are clicked, it changed the main video to the one clicked.

Whenever is pass the variable it all falls apart ?

Can anyone advise me on how to do this?

Thanks

[code]<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js”></script>
<script type=”text/javascript”>$(function() {
$.getJSON(‘http://gdata.youtube.com/feeds/users/fanfairmusic/uploads?alt=json-in-script&callback=?&max-results=1’, function(data) {
$.each(data.feed.entry, function(i, item) {
var title = item[‘title’][‘$t’];
var video = item[‘id’][‘$t’];
video = video.replace(‘http://gdata.youtube.com/feeds/videos/’,’http://www.youtube.com/v/’);
$(‘#youtube’).append(‘<div class=”videoURL”><object width=”480″ height=”385″><param name=”movie” value=”‘+video+’&hl=en_GB&fs=1″></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”‘+video+’&hl=en_GB&fs=1″ type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”480″ height=”385″></embed></object></div>’);
});
});
});
</script>

<script type=”text/javascript”>
$(function() {
$.getJSON(‘http://gdata.youtube.com/feeds/users/fanfairmusic/uploads?alt=json-in-script&callback=?&max-results=20’, function(data) {
$.each(data.feed.entry, function(i, item) {
var title = item[‘title’][‘$t’];
var image = item[‘id’][‘$t’];
var video = item[‘id’][‘$t’];
video = video.replace(‘http://gdata.youtube.com/feeds/videos/’,’http://www.youtube.com/v/’);
image = image.replace(‘http://gdata.youtube.com/feeds/videos/’,”);
$(‘#youtube2’).append(‘<img src=”http://i.ytimg.com/vi/’+image+’/0.jpg” width=”100″ height=”60″ />’);
});
});
});
</script>

<div id=”youtube”></div>
<div id=”youtube2″></div>[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @adamck spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...