473,503 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting a value from a script variable

3 New Member
Hi,

I have this piece of code and I need to get the value of the variable 'filmus1" into the audioplayer line.

Expand|Select|Wrap|Line Numbers
  1. <p id="audioplayer_m">blabla</p>  
  2. <script type="text/javascript" language="JavaScript">
  3. function choosebox1()
  4. {
  5. var filmus="";
  6. var filmus1= "";;
  7. varNumber = <?php echo '"'.$i.'"'; ?>;
  8. for (k=0; k<varNumber; k++) {
  9.       if(document.getElementById('CBT'+k).checked){
  10.             if (filmus==""){
  11.             filmus = filmus + (document.getElementById('CBT'+k).value);}else
  12.             {filmus = filmus + "," + (document.getElementById('CBT'+k).value);}
  13.     }else {}
  14. }
  15. filmus1 = '"' + filmus + '"';
  16. AudioPlayer.embed("audioplayer_m", {soundFile: (get the filmus1 value here), width: 400, autostart: "yes"});
  17. }
  18. </script>
Thanks for any help.
Apr 30 '09 #1
5 1794
dmjpro
2,476 Top Contributor
Expand|Select|Wrap|Line Numbers
  1. AudioPlayer.embed("audioplayer_m", eval('({soundFile: "'+filmus1+'", width: 400, autostart: "yes"})'));
  2.  
I used eval to evaluate JSON object.
May 1 '09 #2
acoder
16,027 Recognized Expert Moderator MVP
Why not use it directly (haven't tested, mind you)?
Expand|Select|Wrap|Line Numbers
  1. AudioPlayer.embed("audioplayer_m", {soundFile: filmus1, width: 400, autostart: "yes"});
Does that not work?
May 1 '09 #3
amarqujo
3 New Member
Expand|Select|Wrap|Line Numbers
  1. <p id="audioplayer_m">Play</p>  
  2. <script type="text/javascript" language="JavaScript">
  3. function choosebox1()
  4. {
  5. var filmus="";
  6. varNumber = <?php echo '"'.$i.'"'; ?>;
  7. for (k=0; k<varNumber; k++) {
  8.       if(document.getElementById('CBT'+k).checked){
  9.             if (filmus==""){
  10.             filmus = filmus + (document.getElementById('CBT'+k).value);}else
  11.             {filmus = filmus + "," + (document.getElementById('CBT'+k).value);}
  12.     }else {}
  13. }
  14. AudioPlayer.embed("audioplayer_m", {soundFile: eval("filmus"), width: 400, autostart: "yes"});
  15. }
  16.  
  17. </script>
May 1 '09 #4
acoder
16,027 Recognized Expert Moderator MVP
Does it not work without the eval?

PS. please use [code] tags.
May 1 '09 #5
amarqujo
3 New Member
Nope, only with eval.
Thanks,
May 1 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2257
by: biner | last post by:
Hello, I have file called PARAMETRES that is used in bourne shell script to define variable. In order to do so I put a ". PARAMETRES" line and the script has acces to all the variable defined in...
3
18176
by: otto | last post by:
i need to read a variable in a javascript and translate it to a form in html the javascript variable is: <SCRIPT LANGUAGE='JavaScript'>RF2N('Total');</script> and i need to put that...
10
2293
by: Chuck | last post by:
Hi! Any ideas as to how I can get ride of the script error undefined variable "Exp_Month"? I am trying to get this drop down list to default to the current month as opposed to 01. Thank...
15
3190
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
3
5867
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
4
4917
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
1
2714
by: robing | last post by:
I am having trouble getting data from a text input field element. the element is called amount_$counter with $counter being the row of the table. when i have made an input to the text field and...
1
3169
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
1
3279
by: satish2112 | last post by:
Hi, I have a text-area which contains values from mysql database and 2 buttons, Edit and Update. When I click on the Edit button, I can edit the text-area (initially non-editable). After this,...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.