Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Pass prameters from Perl to JavaScript

Posted on 1998-11-10
8
221 Views
Last Modified: 2010-03-04
Hello
I need to send parameters from Perl to Java function in an ASP page.
I tried something like this:
------------------------------------------------------
<%
$Parameter1 = "Myname";
$Parameter2 = 2;
$Temp->JavaFunc($Parameter1,$Parameter2, 'String');


%>
<script language="JavaScript" >
function JavaFunc(Parameter1, Parameter2, String)
{
}
-----------------------------------------------------
But I got:
" $Temp->JavaFunc($Parameter1,$Parameter2, 'String'); error '80004005'
  Can't call method "JavaFunc" on an undefined value. "

What wrong? or how can I do it else?.
Thanks
Arnon Ayal
arnon@commtouch.com
0
Comment
Question by:arnonayal
8 Comments
 

Author Comment

by:arnonayal
ID: 1206100
Adjusted points to 150
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1206101
Where did you assign $Temp (or perhaps you forgot to?)
0
 

Author Comment

by:arnonayal
ID: 1206102
I sow an Example that didn't assign the $Temp.
Anyway hou do i do it?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Accepted Solution

by:
ptruman earned 150 total points
ID: 1206103
You can't pass Perl to JavaScript directly.
Perl is a server side system.
JavaScript is client side.

*IF* you know the layout of your returning HTML pages,
you can get Perl to build a <FORM> containing hidden fields
(<INPUT TYPE=HIDDEN NAME=varname VALUE="valueyouwant">)

Then you can have your Javascript functions do something like
newvalue=document.HIDEFORM.elements[1].value
So your perl needs to output
<FORM NAME=HIDEFORM>
<INPUT TYPE=HIDDEN NAME=Output VALUE="1234">
</FORM>

And newvalue will be set to 1234
(you may have to put elements[0] depending on your browser
version)

0
 

Author Comment

by:arnonayal
ID: 1206104
What about RUNAT=server option for the JavaScript?
Isn't it posibble to pass parameters then?
0
 
LVL 4

Expert Comment

by:martinag
ID: 1206105
You do not have to use forms, as ptruman said.

This will do it:
print <<END;
<SCRIPT LANGUAGE="JavaScript">
<!--
JavaFunc('$Parameter1', '$Parameter2', 'String');
// -->
<SCRIPT>
END

Martin
0
 

Author Comment

by:arnonayal
ID: 1206106
Thanks Its help me a lot.
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1206107
Sigh.  Unfortunately, the wrong person got the points :(
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
use perl to insert into MySQL database 9 144
Using Perl DBI to query oracle 3 46
Regular Expression for URL 10 102
How to translate this 2-line while loop into C from Perl? 8 119
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question