sakura
sakura

Reputation: 309

Send data from html form to Java Applet?

I got a problem. I really need your solutions.

Here is the defined problem:

1/ html:

<form name="frm" action="">
    <h3>Enter some data:</h3>
    <table>
    <tr><td>Name: </td>
        <td><input type="text" name="txname" value="" size"20" /></td>
    </tr>
    <tr><td>&nbsp</td>
        <td><input type="button" name="send" value="Send" /></td>
    </tr>
    </table>
</form>
<applet name="myapplet" code="AppletParam.class" width="320" height="120">
    <param name=displayName value="sakura">
</applet>

2/ Is it possible to send data from form to applet tag? In my case I need to send from txname to applet. For example, <param name=displayName value="{txname}">.

Any ideas? please help

Upvotes: 0

Views: 1004

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168825

  1. Have the form do a get request for the page with the applet.
  2. Parse the the data encoded in the URL.
  3. Write the param elements for the applet containing the data in the form fields. Or alternately write the attributes of the deployment toolkit script. This might be done with:-
    • PHP
    • ASP
    • Servlet/JSP
    • Javascript & HTML
    • ..

Upvotes: 2

user2575725
user2575725

Reputation:

There are several ways to do this:

  • Create a method in your applet class say: public void setName(String name), do the needy to reflect the new name in applet.
  • Secondly in your js write code to get the applet with id, say: var myApplet = document.getElementById('myAppletId');
  • Later in js itself, invoke it on event say click or submit,etc whatever suits your scenario, myApplet.setName('new name here');

Upvotes: 1

Related Questions