Solved

Passing parameters to a Java applet from JavaScript

Posted on 1998-10-20
6
413 Views
Last Modified: 2008-03-03
Does anyone know how can I pass parameters to a Java applet on a web page using JavaScript's onclick that calls a function.

I want to be able to pass different parameters to the applet every time a button has been clicked etc.

Any ideas?

By the way. I'm using Netscape 3 under Win95.
0
Comment
Question by:dedo_mraz
  • 3
  • 3
6 Comments
 

Author Comment

by:dedo_mraz
ID: 1272521
Edited text of question
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 1272522
<APPLET NAME="myApplet"....>

<FORM>
<INPUT TYPE="BUTTON" VALUE="javafunction1" onClick="document.myApplet.javafunction1()">
<INPUT TYPE="BUTTON" VALUE="javafunction2" onClick="document.myApplet.javafunction2()">
</FORM>

The functions need to be public and the applet needs to have been loaded first... NS3 is finicky about reloading applets at resize though so be careful...

Michel
0
 

Author Comment

by:dedo_mraz
ID: 1272523
Good one Michel, but...

I know how to invoke methods that are already defined inside the applet and do things.

My question was:

If I have an applet like this...

<applet code="paramtst" name="appletBig"
    width="266" height="150">
        <param name="someNumber" value="12346">
        <param name="someText" value="Whats up Doc?!">
</applet>

How do I pass a parameter to "someNumber" using onclick ?
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.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1272524
I would think
<INPUT TYPE="TEXT" NAME="SomeNumber">
<INPUT TYPE="BUTTON" VALUE="SetSomeNumber"
onClick="document.myApplet.someNumber=parseInt(this.form.SomeNumber);">

but I am not 100% sure on this. Since the parameters are normally read in the init() method, wouldn't it be safer to do a
<INPUT TYPE="BUTTON" VALUE="Set SomeNumber"
onClick="document.myApplet.setSomeNumber(parseInt(this.form.SomeNumber))">
and have a public function to change the parameters.

Michel
0
 

Author Comment

by:dedo_mraz
ID: 1272525
Do you by any chance have a/some URL/s handy that use the above implementation?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1272526
The implementation is pretty straight forward but have a closer look at Live Wire at http://devedge.netscape.com

Michel
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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

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

27 Experts available now in Live!

Get 1:1 Help Now