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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Java Applet Method from JavaScript

Status
Not open for further replies.

sudeepta

Programmer
Oct 31, 2002
6
0
0
IN
HI,

I want to call an method in Java Applet from java script, can anybody please help me out solving this problem.

Presently i am using following code but it is not working with IE but working with NEtscape

import java.lang.String;

public class test extends java.applet.Applet {

public static int countChars(String s) {

return s.length();
}

}

-------------------------------
And my HTML
-------------------------------

<HTML>
<HEAD>
<script language=&quot;Javascript&quot;>
function refreshApplet()
{
/* i = document.forms.myForm.TestApplet.countChars();
document.forms.myForm.output.value=i; */

document.forms.myForm.output.value=document.applets[&quot;TestApplet&quot;].countChars(document.forms.myForm.input.value);
}
</script>
</HEAD>
<BODY>
<APPLET CODE = &quot;test.class&quot; WIDTH = 400 HEIGHT = 400 ALIGN = middle NAME = &quot;TestApplet&quot; scriptable=&quot;true&quot;>
</APPLET>

-------------------------------------

<br>
<form name=&quot;myForm&quot;>
<input type=&quot;text&quot; name=&quot;input&quot;>
<input type=&quot;button&quot; value=&quot;click me&quot; onClick=&quot;refreshApplet();&quot;>
<hr>
<input type=&quot;text&quot; name=&quot;output&quot;>
</form>
</BODY>
</HTML>
 
The Java Sun site has an extreme amount of information on Java and all its uses. In fact, it is a one stop shop for all Java needs. Also, the use of search engines like Google can increase the amount of info available. I suggest that you try these options so that you may better understand the systems and languages you are using instead of posting a question everytime someone suggests a new direction. Learning how to help yourself is much better than depending on others.

MarsChelios
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top