Click to See Complete Forum and Search --> : Applet Parameters


Rype69
12-31-2002, 01:55 PM
Hi Guys,

How do you pass javascript variable values into a java applet as parameters?

Thanx,

Rype69, UK.

spoontacular
12-31-2002, 02:06 PM
You could use a server-side scripting language to insert the values:

<?php
// Using PHP
$param = array();
$param["val1"] = "one";
$param["val2"] = "two";
?>

<applet>
<?php
foreach ($param as $key => $value) {
?>
<param name="<?php echo $key; ?>" value="<?php echo $value; ?>" />
<?php
}
?>
</applet>

khalidali63
12-31-2002, 02:06 PM
I think this is how u would do it.
Say you have an applet name
public class jsApplet Extends java.applet.Applet{
public boolean JSMethod(String param){
return true;
}

}

in your javascript you can probably do something like this

document.JSMethod(param);

I am sure it should work (since its not tested)

Khalid

khalidali63
12-31-2002, 02:07 PM
oops sorry..

wrong post

khalidali63
12-31-2002, 02:08 PM
this is the correct version

I think this is how u would do it.
Say you have an applet name
public class jsApplet Extends java.applet.Applet{
public boolean JSMethod(String param){
return true;
}

}

in your javascript you can probably do something like this

document.jsApplet.JSMethod(param);

missed the class name earlier

spoontacular
12-31-2002, 02:10 PM
If you wanted to do it with JavaScript:

// JavaScript
document.myApplet.setWord("word");

// Java
String word;
public void setWord(String s) {
this.word = s;
}