473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Novice question regarding passing Parameters from JavaScript to an Applet

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.
Jul 20 '05 #1
4 8039
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, 18);

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 ;)
Jul 20 '05 #2
Hi,

ti****@yahoo.co.uk wrote:
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

Jul 20 '05 #3
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.
Jul 20 '05 #4
Hi,

ti****@yahoo.co.uk wrote:
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.

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.

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>

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.
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.

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

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
3
by: Gopal Prabhakaran | last post by:
Dear All, I have 1 class namley classa classa has a method which need a parameter as class methods How shall i pass class method as parameter to another class method. Pls help me asap ...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
0
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
4
by: ingoweiss | last post by:
Hi, I am having trouble passing parameters of a Javascript subclass constructor through to it's superclass constructor. I am trying all sorts of things, including the below, but nothing...
2
by: Nab | last post by:
I have just tried to pass parameters to a procedure in VB 2005 and realised that you only need to pass the input parameter. The output parameter's value will be returned without the need to pass it...
1
by: ponvijaya | last post by:
Hi All, In My project, i am loading an applet in a HTML page using applet tag. And I am passing parameters to applet while loading the applet. In this project , this applet will do...
3
by: JJ | last post by:
I am using a handler (processImage.ashx) to display an image. The image is displayed according to parameters passed in the querystring. The handerl is called via some clientside javascript. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.