Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with passing info to applet  RSS feed

Lawrence Keeney
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I generated the following code in order to transfer data between Javascript and an Applet. However when I do the transfer, the transferred information flashes on the screen and then is erased. I haven't been able to figure out what part of the code is erasing the data.

Can anyone help me?

I am obviously new to Java programming.

import java.applet.*;
import java.awt.*;

public class Transfer extends Applet {
TextField output;
String str = new String("");

public void init()
output = new TextField(4);
public void toCvm(String s)

<title>Data Transfer Test</title>
<!--Test of data transfer between javascript and an applet.-->
<script language="javascript" type="text/javascript">
function xfer(cell)
<body bgcolor="white">
Enter the number to be transferred to the applet...
<form method="post" onSubmit="return xfer(this)">
Enter Number: <input type="text" size="4" name="number">
<input type="submit" value="Submit">

<applet code="Transfer.class" width="60" height="35" name="dataXfer">
Dirk Schreckmann
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Lawrence!

When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.

When you submit the form, the page is being reloaded. That also reloads the Applet, which then includes a new blank TextField.

Offhand, I'm not sure how to make this suggested change, but I'd bet somehow the html can be changed to not submit the form to the server, and have the JavaScript handle it instead.

I'm moving this to the HTML and JavaScript forum, as I believe that the solution you're looking for isn't a Java-based one, but JavaScript-based instead.
[ May 31, 2004: Message edited by: Dirk Schreckmann ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!