jsp页面上怎么写cost=quantity*product.price.....
quantity是我在这张JSP刚输入的
cost是我要存到数据库的。。。
product.price.是从数据库里读取出来的
[code="html"]
function cal() { var price = document.getElementById('product').value; var quantity = document.getElementById('quantity').value; var cost=quantity*product.price; document.getElementById('const').value = const; document.getElementById('addItemForm').submit(); }/s:textfield
headerKey="-1" headerValue="-请选择-"/>
/s:textfield
/s:submit
/s:reset
/s:form
[/code]
[code="html"]
function XXX() { var price = document.getElementById('price'); var quantity = document.getElementById('quantity'); var cost=quantity*product.price; var url = 'XXX.do?method=XX&const=' + const; // 最后提交表单,到Servlet中处理 ...... }[/code]
原理是一样的,我只是提供了你一个思路,你用的应该是Struts2的标签,我给你的例子是HTML标签,但思路都是一样的,即用Javascript来做,点击提交按钮时调用Javascript方法,通过Javascript来取得页面上的值,进行计算后,提交到Action处理....
[code="java"]
function chang(val){
var oCost = document.getElementById('_cost');
var iV = Number('<s:property value="product.price"/>');
oCost.value = val * iV;
}
cost:
product.price:
[/code]