Solved

Pass prameters from Perl to JavaScript

Posted on 1998-11-10
8
218 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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.

770 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