473,654 Members | 3,184 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 1801
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
2268
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 the PARAMETRES file. Now, I would like to be able to get the same thing in python. I googled and played with os.system to try to come up with something but no success so far. I also tryed exec but it doesn't work becaus a lot of string...
3
18205
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 variable as the value in this line <input type="hidden" name="AMT" value="**">
10
2307
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 you in advance.
15
3219
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 tell me why these DIVs don't drift to the left as they are supposed to? <script language="javascript">
3
5875
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 stuff in ASP and PHP so I'm familiar with server-side programming; for some reason JavaScript syntax trips me up. I want to assign a value to a variable according to an onclick event, and then run an if...then on the variable, and according to...
4
4930
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 what I'd like to have happen :
1
2727
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 submitted the onClick passes the table row to the javascript function, i then concatinate a string to be the same as the id of the element i want the input from. i use the script below to get the input but the error i get is...
1
3187
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 follows: The code below is for the first page:session_start is in line 3 <link href="css/jobSheet.css" rel="stylesheet" type="text/css" /> session_start();
1
3296
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, if I click on the Update button, the values in the text-area must be updated in the mysql database. I am storing the values of the text-area in a variable. I am using javascript to pass the variable.
0
8376
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8708
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8594
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1596
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.