/    Sign up×
Community /Pin to ProfileBookmark

How do I echo a variable within another variable?

I have this code:

[CODE]var rand_no = Math.random();
rand_no = rand_no * 100;

var so = new SWFObject(“ep_player.swf?dummyVar=[i want rand_no to be displayed here]”, “ep_player”, “269”, “226”, “9”, “#FFFFFF”);[/CODE]

I want the variable rand_no to be displayed where I specified, how would I do that?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@cgishackFeb 03.2008 — you can create an empty div and add it to that

<i>
</i>var div = document.getElementById("[B]myRandomNumerID[/B]");
div.innerHTML = so;


[code=html]
Random Num: <div id="myRandomNumerID"></div>
[/code]

Drew
Copy linkTweet thisAlerts:
@dizastixauthorFeb 03.2008 — Hey, I'm not sure how I would do that. Here is my entire script section:

[CODE]
<script type="text/javascript">
// <![CDATA[

var so = new SWFObject("ep_player.swf?dummyVar=[here, the random number should be echoed", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_blue/skin.xml");
so.addVariable("playlist", "play.xml");
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("repeat", "false");
so.addVariable("buffertime", "1");
so.write("flashcontent");

// ]]>
</script>[/CODE]


so I don't think I can do that with a div...?
Copy linkTweet thisAlerts:
@cgishackFeb 03.2008 — well it all depends on how that SWFObject works...

I found this
<i>
</i> so.write("flashcontent"); -- [B]replace &amp;#8220;flashcontent&amp;#8221; with the name of the div ID[/B]


Drew
Copy linkTweet thisAlerts:
@dizastixauthorFeb 04.2008 — well it all depends on how that SWFObject works...

I found this
<i>
</i> so.write("flashcontent"); -- [B]replace “flashcontent” with the name of the div ID[/B]


Drew[/QUOTE]


hey, thanks for the help but I ended up just doing it with php since I'm more familiar with that.
×

Success!

Help @dizastix 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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