www.webdeveloper.com
Results 1 to 1 of 1

Thread: Help with passing variable to function?

Threaded View

  1. #1
    Join Date
    Apr 2010
    Posts
    19

    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>
    Last edited by Kor; 06-21-2011 at 08:25 AM. Reason: setting a JQuery prefix

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles