[jQuery] Get value from hidden input and use it in string

2009-11-27 Thread shapper
Hello,

I am using JPlayer to play a sound on a page:
http://www.happyworm.com/jquery/jplayer/0.2.5/demo-04.htm

$(document).ready(function(){

   $(#jquery_jplayer).jPlayer({
  ready: function () {
  $(#trackname).text($(#track-01).text());
  $(this).setFile('http://www.miaowmusic.com/mp3/Miaow-05-The-
separation.mp3').play();
  demoInstanceInfo($(this), $(#jplayer_info));
  }
   })
});

How can I change the setFile code line to:
  $(this).setFile('http://domain.com/asset/get/[id]').play();

Where [id] value should be taken from the following hidden input:
input  TYPE=hidden VALUE=2 NAME=Music

Thank You,
Miguel


Re: [jQuery] Get value from hidden input and use it in string

2009-11-27 Thread brian
Give the input element an ID and use that in the selector:

input  type=hidden value=2 name=Music id=music_id /

$(this).setFile('http://domain.com/asset/get/' +
$('#music_id').attr('id')).play();


On Fri, Nov 27, 2009 at 11:48 AM, shapper mdmo...@gmail.com wrote:
 Hello,

 I am using JPlayer to play a sound on a page:
 http://www.happyworm.com/jquery/jplayer/0.2.5/demo-04.htm

 $(document).ready(function(){

   $(#jquery_jplayer).jPlayer({
      ready: function () {
          $(#trackname).text($(#track-01).text());
          $(this).setFile('http://www.miaowmusic.com/mp3/Miaow-05-The-
 separation.mp3').play();
          demoInstanceInfo($(this), $(#jplayer_info));
      }
   })
 });

 How can I change the setFile code line to:
  $(this).setFile('http://domain.com/asset/get/[id]').play();

 Where [id] value should be taken from the following hidden input:
 input  TYPE=hidden VALUE=2 NAME=Music

 Thank You,
 Miguel