Previous Example-|-Next Example-|-Return to Chapter Listing

Example 13.7:
LiveConnect: Java and JavaScript

[This example works with Netscape Navigator 3. It only partially works with Internet Explorer 3.]

We've created a Java applet named ticket.class, and used a couple of simple scripts to communicate with the applet. Type a number into the text box, then click the Click to Order--an onclick event handler sends a message to the Java applet. Click on the Sold Out button in the Java applet and the applet calls the message function in the HEAD of this Web page.

Welcome to Tickets Online!

Kludge Kowboys in Concert, only $50.00 per ticket.
Please enter number of tickets desired:

We have this script in the HEAD: <SCRIPT LANGUAGE="JavaScript1.1"> <!-- function message(msg1, msg2) { alert(msg1 + msg2) } // --> </SCRIPT> Then this form in the BODY: <FORM NAME="myform"> <INPUT TYPE="text" SIZE="10" NAME="numTickets"> <INPUT TYPE="button" VALUE="Click to Order" onclick="document.ticket.setTicketQuantity(document.myform.numTickets.value)"> </FORM> And this Java applet: <APPLET NAME="ticket" CODE="ticket.class" WIDTH=300 HEIGHT=200 mayscript></APPLET>
Previous Example-|-Next Example-|-Return to Chapter Listing