Results 1 to 7 of 7

Thread: Call Applet functions from website (js?)

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Call Applet functions from website (js?)

    How can I call a function and pass parameters to a applet from my website? For example I want the user to enter name and password into textboxes and then click a button which calls the function login(name, pw) from my java applet. Best would be something using POST/GET but a javascript would also work..

    There are several things why I don't want the textbox to be in the applet so please show me how to make website and applet work together,

    Thanks

  2. #2

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    no one? I just need to get homepage and applet work together!

  3. #3
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181
    no one's replying and i don't know much about applets. but i'll give it a shot.

    under the Applet there is a method called getParameter
    http://java.sun.com/j2se/1.4/docs/ap...l#getParameter(java.lang.String)

    i'm not sure, but if you could use that to pass in whatever info you need to be passed.
    the api explains how it's used. check it out. goodluck

    --770

  4. #4

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Nope that's only to read parameters from the website code..

    <param name="text" value="hello world">

    this one..

  5. #5
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181
    hmm...

    have you browsed the api for more methods?

    i just though of this. use php to get the input, put it in a cookie and read the cookie from the applet.. (although i'm not sure if that's possible)

    i'm just spitting out possibilies.

    --770

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Are you looking for something like this??
    Code:
    <HTML>
     <HEAD>
      <SCRIPT LANGUAGE="JavaScript">
       <!-- Begin
        function send_request(objForm)
         {
          var name = objForm.userid.value
          var pw = objForm.passwd.value
          
          // you might want to do some edits here, i.e.
          if (name.length == 0)
             {
              alert('Userid required')                 // displays in a message box
              objForm.userid.focus()
              return
             }
          if (pw.length == 0)
             {
              self.defaultStatus = 'Password required' // displays in the status bar
              objForm.passwd.focus()
              return
             }
    
          document.myJavaApplet.login(name, pw) 
         }
       //  End -->
      </SCRIPT>
     </HEAD>
     <FORM>
      <BODY>
       <!-- Note: HEIGHT="1" WIDTH="1" hides the applet -->
       <APPLET NAME="myJavaApplet" CODE="myApplet.class" HEIGHT="1" WIDTH="1"> </APPLET>
       <INPUT TYPE="TEXT" NAME="userid" SIZE="8">
       <INPUT TYPE="TEXT" NAME="passwd" SIZE="8">
       <INPUT TYPE="BUTTON" NAME="login" VALUE="Login" ONCLICK="send_request(this.form);">
      </BODY
     </FORM>
    </HTML>

  7. #7

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Eeeeeeeexactly, thanks loads!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width