Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing the document object from javascript

Status
Not open for further replies.

harmmeijer

Programmer
Mar 1, 2001
869
CN
How do I get the value of my textbox "txt" in the string myString without passing the value as string but passing the entire document object. The applet can do a getElementById on this object.
I am using IE 5.0


this is the applet:
import java.applet.*;
import java.awt.*;

/**
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
*/
public class HelloWorld extends Applet {
String myString;
public void paint(Graphics g) {
// Display "Hello World!"
g.drawString(myString, 50, 25);
}
public void setString(String objDocument) {
myString = "aaa hlkdjsf"; // this.getContext().getElementById("txt").value;
repaint();
}
}


this is the HTML page:
<HTML>
<HEAD>
<TITLE>A Simple Program</TITLE>
</HEAD>
<BODY>
Here is the output of my program:
<APPLET id=&quot;app&quot; name=&quot;app&quot; CODE=&quot;HelloWorld.class&quot; className=&quot;&quot; WIDTH=400 HEIGHT=25 VIEWASTEXT>
</APPLET>
<form id=frm>
<input type=button onclick=&quot;document.app.setString();&quot;>
<input type=text id=&quot;txt&quot; name=&quot;txt&quot;>
</form>

<script>
objApp = document.getElementById('app');
// alert(objApp.getParam());
// alert(objApp.HelloWorld.getParam);

</script>

</BODY>
</HTML>

 
solved:

To compile Java code to take advantage of JSObject, you must have the package netscape.javascript in the CLASSPATH. Currently, Java Plug-in 1.2.2 ships netscape.javascript in a JAR file called JAWS.JAR. To compile an applet which uses JSObject, please add JAWS.JAR in the CLASSPATH before compilation.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top