Scripts and Applet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roberto Gallo

    Scripts and Applet


    Hi;

    I have two problems regarding Scripts and Applets. I need to construct a
    page that has some instances of the same Applet. These instances are
    responsible to get informations from the user and the system. The
    information is latter sent to the site.

    How can I reference distinct Applets instances of the same Applet Class
    inside the page?
    How can I get the values stored in the Applet's variables using
    JavaScript?

    Thank you
    Roberto Gallo.




  • Martin Honnen

    #2
    Re: Scripts and Applet



    Roberto Gallo wrote:
    [color=blue]
    > I have two problems regarding Scripts and Applets. I need to construct a
    > page that has some instances of the same Applet. These instances are
    > responsible to get informations from the user and the system. The
    > information is latter sent to the site.
    >
    > How can I reference distinct Applets instances of the same Applet Class
    > inside the page?
    > How can I get the values stored in the Applet's variables using
    > JavaScript?[/color]

    Well, for JavaScript is doesn't matter what class an applet is an
    instance of, if you use an <applet> element like
    <applet name="applet1" ...>...</applet>
    then Javascript can access
    var applet = document.applet s.applet1;
    Then you can check
    if (applet.methodN ame) {
    var s = applet.methodNa me();
    }
    and the applet should have a public method methodName that returns the
    value you want from the applet.

    --

    Martin Honnen


    Comment

    • Nordine Vandezande

      #3
      Re: Scripts and Applet

      Martin Honnen wrote:[color=blue]
      >
      >
      > Roberto Gallo wrote:
      >[color=green]
      >> I have two problems regarding Scripts and Applets. I need to
      >> construct a
      >> page that has some instances of the same Applet. These instances are
      >> responsible to get informations from the user and the system. The
      >> information is latter sent to the site.
      >>
      >> How can I reference distinct Applets instances of the same Applet
      >> Class
      >> inside the page?
      >> How can I get the values stored in the Applet's variables using
      >> JavaScript?[/color]
      >
      >
      > Well, for JavaScript is doesn't matter what class an applet is an
      > instance of, if you use an <applet> element like
      > <applet name="applet1" ...>...</applet>
      > then Javascript can access
      > var applet = document.applet s.applet1;
      > Then you can check
      > if (applet.methodN ame) {
      > var s = applet.methodNa me();
      > }
      > and the applet should have a public method methodName that returns the
      > value you want from the applet.
      >[/color]
      Be aware that you have to be sure that the applet is already loaded
      before you call any methods. Otherwise you will get a 'applet.methodN ame
      is not a function'-error (at least for Mozilla on Linux, at Windows it
      works fine for IE and Mozilla).

      Comment

      Working...