473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pass variables from Perl to Ajax and back

Hi everybody, I'm creating a website with HTML / Javascript embeded in perl code. I use perl to get values from a MySQL database which I need to feed a chart created with the javascript code so the chart can be updated on the fly. Everything works perfectly well except I don't know how the perl variable values can be passed to the javascript within the same document.

Here is abbreviated example code:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use CGI;
  3. use sctrict;
  4.  
  5. $Type = 'line';
  6. $width = '200';
  7. $line_color ='#FF0000';
  8. $fillColor = '#FFFF00',
  9. $height = '20';
  10.  
  11. ### I NEED TO POPULATE THE BELOW DOTED LINES WITH THE ABOVE VARIABLES  ###
  12.  
  13. print q~
  14.  
  15.   <script>
  16.  
  17.     $(document).ready(function () {
  18.  
  19.      $("#sparkline4").sparkline([34, 43, 43, 35, 44, 32, 15, 22, 46, 33, 86, 54, 73, 53, 12, 53, 23, 65, 23, 63, 53, 42, 34, 56, 76, 15, 54, 23, 44], {
  20.             type: '........',
  21.             lineColor: '.....', 
  22.             fillColor: '.......',
  23.             width: '......',
  24.             height: '.....'
  25.         });
  26.  
  27.    });
  28.  
  29. var hellow_world: 'Hello World';
  30.  
  31. </script>
  32. ~;
  33.  
  34. $HELLO_WORLD = "..........";
  35.  
  36. ### ----- END OF PERL CODE ---- ### 
  37.  

Also I need to do this the other way around. The value of the hellow_worl javascript variable need to populate the dots in the $HELLO_WORLD perl variable.

Thanx a million
webvirtual
May 4 '17 #1
0 4421

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

Similar topics

2
by: blurz | last post by:
Hi, would like to know whether I can use ViewState to pass variables from one web page to another. I've been trying do this but all I managed to do is to pass the variable to the target page but...
7
by: Andy Fish | last post by:
Hi, I have a javascript solution where page A launches page B in a second window and then they can pass data between them. That's all well and good. Now say page B wants to navigate to page C...
0
by: Sam | last post by:
I'm wondering if I can pass variables to "TestForm.aspx" with the way I'm using it. It's acting as a jpeg image and looks like: <%@ Page ContentType="image/Jpeg" %> <%@ Import...
5
by: Nate | last post by:
Is there any way within asp.net to pass user defined parameters/variables to an executable? Much thanks. nate
5
by: adolf garlic | last post by:
Suggestions please for strategy to share values across app. Scenario: I have an asp.net app that uses some com components along with .net classes. Configuration settings for various things...
7
by: Gladen Blackshield | last post by:
Hello All! Still very new to PHP and I was wondering about the easiest and simplest way to go about doing something for a project I am working on. I would simply like advice on what I'm asking...
3
by: pedjasmek | last post by:
I have one link in the second script that leads to the first one.How can I pass variables from the second script to the first one? I cannot use $_GET $_POST variables because I don't use those...
1
by: adpinc | last post by:
Hello all! I am a seasoned programmer, but not really with Javascript. I have a strange phenomenon going on that for the life of me I cannot figure out what is wrong. I am calling a javascript...
1
by: akarsh | last post by:
Hi, I am using AJAX in one of my application and because of it I am getting the problem of AJAX back button. So can u tell me please that how to solve this problem.
4
by: ghjk | last post by:
I want to pass 2 variables in my php page to ajax page in onchange function. Actually this drop down box use in many pages. So I want to pass the page name to ajax page with the user selected value....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.