Solved

Passing parameters to a Java applet from JavaScript

Posted on 1998-10-20
6
407 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

707 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