Microsoft KB Archive/177161

{|
 * width="100%"|

HOWTO: Getting an Applet to Submit Information

 * }

ID: Q177161

-

The information in this article applies to:


 * Microsoft SDK for Java, versions 1.51, 2.0, 2.01, 2.02, 3.0, 3.1, 3.2

-

SUMMARY
When I have an applet in a  it doesn't submit any information to the server. How can I get the applet to submit its information?

MORE INFORMATION
The applet doesn't submit any information because the information a user would want to submit is specific to the applet. For example, an applet that shows images may want to submit the currently displayed image number, while an applet that displays a clock may want to submit the GMT time. It is up to the programmer to write the methods to submit the applet. The five steps below show one way you might implement submitting an applet.

  Create an applet with a public function that returns the information you want to submit. (For the first example above, you would return the image number.) public int getCurrentImage { return m_nCurrImage; }  Create a Web page with an applet inside your form. Create a hidden field in the , where your applet will submit its data. Write a script function, like processApplet in the example below, to populate the hidden field by calling public functions of your applet.  Set your submit button's onClick function to call the script function you wrote in step 4. Here is the finished product:   <input type=hidden name="appletImage"> <script language=JScript> function processApplet {     parent.myForm.appletImage.value=document.myForm.myapplet. getCurrentImage; alert("Sending form: image="+parent.myForm.appletImage.value+"     user="+parent.myForm.Username.value); }  Username:<input type=text name="Username"> <input type=submit value="Please send me the above picture." language="JScript" onClick="processApplet;"> </li></ol>