Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML to Applet

 
Revati Pathak
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have a html file including applet tag.in addition to that i have a a button on the same HTML page. i have a textfield in my applet. now, on click of the button in the i want to set the value of the textField in the applet.
is it possible?
can any one help me for the same?

regards,
Revati
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question would be great for the HTML/JavaScript forum. This is how you do it:
1) The function and class that you want to access must be declared public.
2) The Applet [b]must[b] finish loading before it can be accessed.
3) In your HTML, provide a name for the Applet by using the name attribute of the <APPLET> tag.
4) Access your applet's methods using the applet object of JavaScript.
For example, if I have an applet with a public function called setTextboxText(String s), I can access that function as follows:

That should do it for you. HTH
[This message has been edited by Bodie Minster (edited March 08, 2001).]
 
Revati Pathak
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friend,
i have already tried this but i am not vable to access the members of applet using the name of the Applet tag.
is there any other way to do it?
thanks for your reply.
regards,
Revati


That should do it for you. HTH
[This message has been edited by Bodie Minster (edited March 08, 2001).][/b]<HR></BLOCKQUOTE>
[This message has been edited by Revati Pathak (edited March 09, 2001).]
[ July 21, 2002: Message edited by: Marilyn de Queiroz ]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the only way that I know of. What browser are you using? Netscape didn't add this feature until Navigator3 and IE didn't support it until IE4. You might try using the for in construct to print out the elements in the document collection. You would do that like this:

You might also try embedding the text field, button, and applet in a <FORM>.
[This message has been edited by Bodie Minster (edited March 09, 2001).]
 
Revati Pathak
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for ur ans. To worked!!! can u please ans this query.
I want to set the value of a textfield in the html form to a variable obtained from the applet. This should happen on the click event of a button in the applet.In short i want to refer to a textfield in html(that contains the applet) page from the applet
Originally posted by Bodie Minster:
[B]This question would be great for the HTML/JavaScript forum. This is how you do it:
1) The function and class that you want to access must be declared public.
2) The Applet [b]must[b] finish loading before it can be accessed.
3) In your HTML, provide a name for the Applet by using the name attribute of the <APPLET> tag.
4) Access your applet's methods using the applet object of JavaScript.
For example, if I have an applet with a public function called setTextboxText(String s), I can access that function as follows:

That should do it for you. HTH
[This message has been edited by Bodie Minster (edited March 08, 2001).][/B]

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic