2

I need to "send" a variable to a div a via a javascript that you helped me set up a year or so ago. Basically...

The variable playlist I've got set up comes from:

<script language="JavaScript" type="text/javascript">
 var play = '<?php echo "$play"; ?>';
 var playlist = "playlists/" + play + ".xml";
 ***command to send to "var_playlist" ****;
</script>

And then needs to get sent to:

<!--START - PICKLE PLAYER -->
<div data-media="var_playlist"></div>
<!-- END - PICKLE PLAYER -->

Thanks so much for any help!!!

1
  • 2
    What do you mean by "send"? Does that "pickle player" have some API, could you link to it? What have you tried? And: Why does it need JavaScript, can't you just set the div up with PHP? Commented Aug 5, 2012 at 4:12

3 Answers 3

1

Try this:

document.querySelector('div[data-media]').innerHTML = playlist; 

Or if you want to change the value of data-media attribute you can try:

document.querySelector('div[data-media]').dataset.media = playlist;

DEMO

Sign up to request clarification or add additional context in comments.

Comments

0

http://jsfiddle.net/V4aCC/

It's tough to know what you mean by "send". The linked JSFiddle will place the text contained in a Javascript string into the HTML of the element.

Comments

0

It looks like you want to set the data-media attribute to the value of playlist, you can use setAttribute

mediadiv.setAttribute('data-media', playlist);//where mediadiv is the div in question

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.