?
Solved

Passing parameters to a Java applet from JavaScript

Posted on 1998-10-20
6
Medium Priority
?
432 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
[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
  • 3
  • 3
6 Comments
 

Author Comment

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

Accepted Solution

by:
Michel Plungjan earned 300 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
Technology Partners: 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 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

Technology Partners: 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!

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

777 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