在javascript和java applet之间传递数据

时间:2012-04-12 13:38:32

标签: java javascript

我有一个JavaScript函数,我在这里发布并得到了一些答案。我需要更多帮助,以便我能够清楚地操作代码:

function printreceipt(tax,subtotal,total)
{
    subtotalElem=document.getElementById("total");
    var taxElem=document.getElementById("tax");
    productElem=document.getElementById("product-name");
    alert("here are my products" + taxElem.innerHTML + subtotalElem.innerHTML);
}

我问过如何将JavaScript变量发送到JAVA applet,答案是将其添加到JavaScript中:

var myApp = document.applets['myApplet'];
myApp.receiveData(taxElem.innerHTML + subtotalElem.innerHTML);

建议我将此代码放在JAVA applet中

public void receiveData(String dataFromJS)
{
     //Do what you need with your data
}

我了解了如何包含公共函数来从applet中检索数据,但是当我部署applet时,它不会检索数据 - 它是空的。

  • 如何以字符串的形式获取数据,例如税收内容。
  • 如何在代码中添加参数以检索元素的内容,例如tax。
  • 如何在小程序中显示数据?

0 个答案:

没有答案