javascript - creating dynamic playlist by reading songs from a table using jquery for the jPlayer -


i using jplayer website. now, want create playlist table path , artist names. did added table page , now, using foreach tried read path , add playlist. somehow confused.. have code used grabbing path , works fine

    <script type="text/javascript">     $(document).ready(function () {         $('#songspathgridview tr').each(function () {             if (!this.rowindex) return; // skip first row             var path = this.cells[0].innerhtml;             alert(path);          });     }); </script> 

and playlist have (hard coded values). if in html or have appended path since it's jquery code please tell me how it.. here playlist code

  <script type="text/javascript">     $(document).ready(function () {         var songname = "song1";         var theartist = "the artist";         var myplaylist = [             {                 mp3: 'music/mad.mp3', oga: 'mix/1.ogg', title: songname, artist: theartist,             },           {               mp3: 'mix/essentialviolet.mp3', oga: 'mix/2.ogg', title: songname, artist: theartist, cover: 'mix/2.jpg'           }         ];         $('body').ttwmusicplayer(myplaylist, {             autoplay: false,              jplayer: {                 swfpath: '../plugin/jquery-jplayer' //you need override default swf path time directory structure changes             }         });     }); </script> 

somehow wanna filepath , add dynamically. please help, thanks.

i'd see html code you're using table, because impact construction, method should work:

$(document).ready(function () {      var myplaylist = [{}]; // empty object push      $('#songspathgridview tr').each(function () {         if (!this.rowindex) return; // skip first row         // push each row's data myplaylist variable         // expects mp3 path @ column 0, title @ column 1, artist @ column 2         myplaylist.push( { mp3: this.cells[0].innerhtml, title: this.cells[1].innerhtml, artist: this.cells[2].innerhtml } );     });      $('body').ttwmusicplayer(myplaylist, {         autoplay: false,         jplayer: {             swfpath: '../plugin/jquery-jplayer' //you need override default swf path time directory structure changes         }     });  }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -