Solved

Pass prameters from Perl to JavaScript

Posted on 1998-11-10
8
224 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
[X]
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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Six Sigma Control Plans

628 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