在javascript和java小程序之间传递数据
我在这里发布了一个JavaScript函数,并得到了一些答案。我需要更多帮助,以便能够清楚地操作代码:在javascript和java小程序之间传递数据,java,javascript,Java,Javascript,我在这里发布了一个JavaScript函数,并得到了一些答案。我需要更多帮助,以便能够清楚地操作代码: function printreceipt(tax,subtotal,total) { subtotalElem=document.getElementById("total"); var taxElem=document.getElementById("tax"); productElem=document.getElementById("product-name")
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小程序,答案是将其添加到JavaScript中:
var myApp = document.applets['myApplet'];
myApp.receiveData(taxElem.innerHTML + subtotalElem.innerHTML);
建议我将此代码放入JAVA小程序中
public void receiveData(String dataFromJS)
{
//Do what you need with your data
}
向我展示了如何包含从小程序检索数据的公共函数,但是当我部署小程序时,它不会检索数据-它是空的
- 如何以字符串的形式获取数据,如tax中的内容
- 如何在代码中添加参数以检索元素(如tax)的内容李>
- 如何在小程序中显示数据