AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Novice question regarding passing Parameters from JavaScript

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.javascript
View previous topic :: View next topic  
Author Message
timwap@yahoo.co.uk
Guest





PostPosted: Mon Jul 14, 2003 4:46 pm    Post subject: Novice question regarding passing Parameters from JavaScript Reply with quote



I hava a Java Applet that produces a DTMF tone at a certain time of
day.
There are 4 parameters to the Applet, they are
hour = Hour of triggered event 00~23
min = minute of triggered event 00~59
sec = Second of triggered event 00~59
tone = DTMF Tone to play 0~9 A~F # & *

I now need to write a HTML/JavaScript web page that will enable me to
pass these 4 parameters to the applet.
I do know that the code to pass the values will be something like
this:-

<APPLET CODE="ToneTrig.class" WIDTH=100 HEIGHT=100>
<PARAM NAME="hour" VALUE= value selected in a drop down form menu>
<PARAM NAME="min" VALUE = value selected in a drop down form menu>
etc etc etc
</APPLET>

The bit I'm unsure about is how to have the JavaScript wait till you
have selected the required vales then proceed to trigger the applet.
Does it have to be in the shape of a form or is a simple button
needed?

I'm very new to JavaScript & Java coding so please try and explain it
in a way that a newbie may understand ;)

Many thanks.
Back to top
timwap@yahoo.co.uk
Guest





PostPosted: Tue Jul 15, 2003 11:46 am    Post subject: Re: Novice question regarding passing Parameters from JavaSc Reply with quote



Wow. Thanks for that.

It's going to take me a while to assimilate that knowledge.

Still a bit confused in the script as to what is a variable and what
is a command. But will fugure it out I'm sure.

Perhaps you could take a look at what I've done so far at the
following address & script and tell me where I'm going wrong:-

http://www.entropy1024.pwp.blueyonder.co.uk/DTMF/

This JavaScript should then pass the 4 variables to the following
Applet.


========

import java.awt.Font;
import java.awt.Graphics;
import java.util.Date;
import java.applet.*;
import java.awt.Graphics;
import java.applet.AudioClip;

public class Applet_1 extends java.applet.Applet {

int chour, cmin, csec = 0;

String str = "Default";
String hour = "Default";
String min = "Default";
String sec = "Default";
String tone = "Default";
public void paint(Graphics g) {
Font f = new Font("TimesRoman", Font.PLAIN, 1Cool;

String str = getParameter("text");
String thour = getParameter("hour");
String tmin = getParameter("min");
String tsec = getParameter("sec");
String ttone = getParameter("tone");

g.setFont(f);
//g.drawString(str, 10, 25);
g.drawString(thour, 10, 25);
g.drawString(tmin, 10, 50);
g.drawString(tsec, 10, 75);
g.drawString(ttone, 25, 25);

do {
Date CurrentTime = new Date();
chour = CurrentTime.getHours();
cmin = CurrentTime.getMinutes();
csec = CurrentTime.getSeconds();


//g.drawString(csec, 75, 25);

if (sec == tsec)
if (min == tmin)
break;
else {
}
else {
}


} while (hour != "00");


System.out.println("BEEP!");

}
}


========

PS.
I did not code the Java clock. That was a freebie from someone else Wink
Back to top
Laurent Bugnion, GalaSoft
Guest





PostPosted: Tue Jul 15, 2003 11:53 am    Post subject: Re: Novice question regarding passing Parameters from JavaSc Reply with quote



Hi,

[email]timwap (AT) yahoo (DOT) co.uk[/email] wrote:
Quote:
Wow. Thanks for that.

It's going to take me a while to assimilate that knowledge.

Still a bit confused in the script as to what is a variable and what
is a command. But will fugure it out I'm sure.

Perhaps you could take a look at what I've done so far at the
following address & script and tell me where I'm going wrong:-

http://www.entropy1024.pwp.blueyonder.co.uk/DTMF/

This JavaScript should then pass the 4 variables to the following
Applet.

With this applet (code snipped), you have no way to pass the parameters
dynamically (using LiveConnect) because the applet has no public method
allowing you to do so. Modifying the applet would be trivial, but...
probably not possible for you (no offense ).

I would simply use my second proposal (the document.write) if I were you.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch


Back to top
timwap@yahoo.co.uk
Guest





PostPosted: Tue Jul 15, 2003 2:07 pm    Post subject: Re: Novice question regarding passing Parameters from JavaSc Reply with quote

Thanks again for the guidance. I feel I'm so close to getting this
thing working but still keep falling down.

Your JavaScript, although intimidating to the likes of me, does make
sense. The bit I have trouble understanding is the following line.

document.write( strAppletCode );

A few lines above is the command 'var strAppletCode =...' so I guess
strAppletCode is a variable. It also looks like this variable will be
loaded with the Applet code & name, width & height plus hour, min, sec
& tone parameters.

So if I had selected a trigger time of 10:20:30 and the tone 'A' then
strAppletCode would contain the following info:
'<APPLET CODE="ToneTrig.class" WIDTH="100" HEIGHT="100">', 10, 20, 30,
A

Is this anywhere near right? I hope so ;)

Then 'document.write( strAppletCode );' would pass this data to the
applet. I have not been able to find any reference to the
'document.write' command in my Jscript manual. Thats if it is a
command.

What do I need to put in my Applet to get it to recieve these
variables? Is it the 'getParameter' command or something else? I
suspect the latter.

Many thanks.
Back to top
Laurent Bugnion, GalaSoft
Guest





PostPosted: Tue Jul 15, 2003 5:11 pm    Post subject: Re: Novice question regarding passing Parameters from JavaSc Reply with quote

Hi,

[email]timwap (AT) yahoo (DOT) co.uk[/email] wrote:
Quote:
Thanks again for the guidance. I feel I'm so close to getting this
thing working but still keep falling down.

Your JavaScript, although intimidating to the likes of me, does make
sense. The bit I have trouble understanding is the following line.

document.write( strAppletCode );

The method document.write() writes some HTML code into the current
document. This HTML code is then interpreted by the browser. It is
handled as if it was normal HTML code.


Quote:
A few lines above is the command 'var strAppletCode =...' so I guess
strAppletCode is a variable. It also looks like this variable will be
loaded with the Applet code & name, width & height plus hour, min, sec
& tone parameters.

The variable strAppletCode is a String of characters, which contains
exactly this code:

<APPLET CODE="ToneTrig.class" WIDTH="100" HEIGHT="100">
<PARAM NAME="hour" VALUE="HH">
<PARAM NAME="min" VALUE="MM">
<PARAM NAME="sec" VALUE="SS">
<PARAM NAME="tone" VALUE="TT">
</APPLET>

However, it is built dynamically, and the HH, MM, SS and TT are replaced
by (resp.) Hour, Minutes, Seconds and Tone chosen by the user.


Quote:
So if I had selected a trigger time of 10:20:30 and the tone 'A' then
strAppletCode would contain the following info:
'<APPLET CODE="ToneTrig.class" WIDTH="100" HEIGHT="100">', 10, 20, 30,
A

Rather:

<APPLET CODE="ToneTrig.class" WIDTH="100" HEIGHT="100">
<PARAM NAME="hour" VALUE="10">
<PARAM NAME="min" VALUE="20">
<PARAM NAME="sec" VALUE="30">
<PARAM NAME="tone" VALUE="A">
</APPLET>


Quote:
Is this anywhere near right? I hope so ;)

Then 'document.write( strAppletCode );' would pass this data to the
applet. I have not been able to find any reference to the
'document.write' command in my Jscript manual. Thats if it is a
command.

It doesn't pass it to the applet, it writes the HTML code for the
applet, including the parameters. The browser then starts the applet,
which gets the parameters (using getParameter, as you found out) and
handles them.

Quote:
What do I need to put in my Applet to get it to recieve these
variables? Is it the 'getParameter' command or something else? I
suspect the latter.

I believe it should work fine.

Quote:

Many thanks.

No probs,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.javascript All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.