简体   繁体   中英

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

  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
    • ..

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM