Solved

Pass prameters from Perl to JavaScript

Posted on 1998-11-10
8
215 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

22 Experts available now in Live!

Get 1:1 Help Now