Hi there,
I saw an example of how to get form data to a Java applet. But how do I get it the other way around? Push a button, read data from an applet and show it in a standard HTML form (like textarea or something)
The code to write form data to a Java applet can be found here: thread269-2280 Can somebody modify it for me, so that I can get data from a applet to a form?
I tried to do it myself, but I just don't get it![[sadeyes] [sadeyes] [sadeyes]](/data/assets/smilies/sadeyes.gif)
B2d
---
FormDataToApplet.html:
**********************
<FORM onSubmit="return false">
Please, give your name:
<INPUT TYPE="text" NAME="yourname" SIZE=40>
<INPUT TYPE="submit" value="Pass data" onClick="
document.FD.writeName(yourname.value);">
</FORM>
<HR>
<APPLET CODE=FormDataToApplet.class NAME=FD height=100 width=200>
</APPLET>
FormDataToHtml.java:
********************
import java.applet.Applet;
import java.awt.*;
public class FormDataToApplet extends Applet {
String name;
public void init() {
setBackground(Color.green);
}
public void paint(Graphics g) {
if (name!=null) {
g.setColor(Color.red);
g.drawString("Hi, "+name, 10, 10);
}
}
public void writeName(String s) {
name=s;
repaint();
}
}
I saw an example of how to get form data to a Java applet. But how do I get it the other way around? Push a button, read data from an applet and show it in a standard HTML form (like textarea or something)
The code to write form data to a Java applet can be found here: thread269-2280 Can somebody modify it for me, so that I can get data from a applet to a form?
I tried to do it myself, but I just don't get it
![[sadeyes] [sadeyes] [sadeyes]](/data/assets/smilies/sadeyes.gif)
B2d
---
FormDataToApplet.html:
**********************
<FORM onSubmit="return false">
Please, give your name:
<INPUT TYPE="text" NAME="yourname" SIZE=40>
<INPUT TYPE="submit" value="Pass data" onClick="
document.FD.writeName(yourname.value);">
</FORM>
<HR>
<APPLET CODE=FormDataToApplet.class NAME=FD height=100 width=200>
</APPLET>
FormDataToHtml.java:
********************
import java.applet.Applet;
import java.awt.*;
public class FormDataToApplet extends Applet {
String name;
public void init() {
setBackground(Color.green);
}
public void paint(Graphics g) {
if (name!=null) {
g.setColor(Color.red);
g.drawString("Hi, "+name, 10, 10);
}
}
public void writeName(String s) {
name=s;
repaint();
}
}