Solved

Pass prameters from Perl to JavaScript

Posted on 1998-11-10
8
217 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now