473,625 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing a perl variable to html using javascript

9 New Member
Hello gits,

I found this snippet that you offered to another person and I was wondering if it wouldn't work for me as well:

<script type="text/javascript">
function do_onload() {
alert('hello');
}
</script>
<body onload="do_onlo ad();">

In my perl script I am using the following two lines of codes to store a variable ($ewstring) and then access a html table (all.html) using $ewstring:

$ewstring = substr($string[$count - 1],3);
$thisrow = $thisrow . "<td>" . $myfont . "<a href=/Operations/all.html#$ewstr ing style=text-decoration:none ><font color=#000000>" . substr($string[$count - 1],3) . "</a>";

Is it possible to pass $ewstring from the perl script to the javascript and use that variable in place of 'hello'????

Thanks.
Jul 18 '07 #1
6 3182
roop1
9 New Member
Hello,

I was wondering if the following javascript wouldn't work for what I am trying to do:

<script type="text/javascript">
function do_onload() {
alert('hello');
}
</script>
<body onload="do_onlo ad();">

In my perl script I am using the following two lines of codes to store a variable ($ewstring) and then access a html table (all.html) using that $ewstring:

$ewstring = substr($string[$count - 1],3);
$thisrow = $thisrow . "<td>" . $myfont . "<a href=/Operations/all.html#$ewstr ing style=text-decoration:none ><font color=#000000>" . substr($string[$count - 1],3) . "</a>";

Is it possible to pass $ewstring from the perl script to the javascript and use that variable in place of 'hello'????

Thanks.
Jul 19 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
THreads merged. Please do not double post.
Jul 19 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
You can try using the location.search property.
Jul 19 '07 #4
roop1
9 New Member
You can try using the location.search property.

Thanks. But how do I code the perl script to pass the variable?
Jul 19 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Thanks. But how do I code the perl script to pass the variable?
Does all.html have to be a HTML file? If it could be a Perl file, just use Perl to replace "hello" with the variable retrieved from the URL (which I'm sure you can do).

If not, make sure the URL is "all.html?var=" .$ewstring (you may need to encode the string to deal with special characters)

Then parse the string using the location.search property. If you start from substring(1), you'll have var=.. Then use the split method to split the variable into a name-val pair. This is assuming this is the only value passed.
Expand|Select|Wrap|Line Numbers
  1. var urlparams = location.search.substring(1);
  2. var params=urlparams.split("=");
  3. var val = params[1];
Jul 20 '07 #6
roop1
9 New Member
Thanks and yes all.html have to be a HTML file? I'll try what you suggested.

Just to be sure, are you saying to replace:

"<a href=/Operations/all.html#$ewstr ing ......

with

"<a href=/Operations/all.html?var=.# $ewstring ......?

Thanks again.
Jul 20 '07 #7

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

Similar topics

3
12870
by: Jeanne | last post by:
I am working on a cgi script that is suppose to pop-up a javascript box from the following perl variables:$TodayDate, $LinkCity, $LinkState. I recently encountered a problem with the $LinkCity variable when the city Coeur d'Alene was read. It appears that javascript is intrepreting the quote to end after d'. I've tried reversing the quotes (instead of " ' ' ", ' " " ') and using the javascript escape command. Neither worked. Please help!...
26
45497
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
6
5577
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an object collection and stanrd using it it starts to fall apart. Clearly there is something about javascript's usage of passing "By ref" that i am not getting. i have had a look on the web and found some examples, but i cant see why my code does not...
3
6776
by: stahl.karl | last post by:
I have a CGI/Perl program that returns a string output. Is it possible to get this into a Javascript variable, where the name of the variable is defined in the Javascript and not in the Perl code? For example, it seems that the following should work, but it doesn't appear to. Is this valid code? CGI code --- get_string.pl ------ print "Content-type: text/plain\n\n";
2
4868
by: pleaseexplaintome | last post by:
Hi I have the following perl/cgi script snippet. The goal of this script is to pass a javascript variable to perl where it can be re-used later. Any help is appreciated, Thanks #!/ois/usr/bin/perl -w use strict; use CGI qw(:standard); my $cgi=new CGI; my $flg=0;
8
5476
by: Harch84 | last post by:
Hi I have a html page with javascript in it that assigns a set of coordinates to javascript variables. The question I have is how can I then send these variables to a Perl CGI script using a submit on a html form. An example of some of the code below: var map; var geocoder = null; var addressMarker;
1
3295
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.
1
3608
by: bpejman | last post by:
Hi Everyone, I've been reading and searching the web for days trying to figure out how exactly you can access and read a Perl array or hash from within JavaScript. I've been reading that JSON is the way to go, but non explain exactly how. If you can help me out, I would really appreciate it. Here's the scenario I have... I have a perl file called index.pl and in this file I have the below code. I know that arrays are converted to...
3
2394
by: sasimca007 | last post by:
Hello friends, IN modperl we write perl with html,javascript and etc. when we are writing perl code in the middle of javascript and if we want to assign a javascript variable to a perl variable, how it is possible?(Without using Ajax). Urgent friends
0
8251
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
8182
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
8688
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...
1
8352
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8494
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
7178
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.