<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>发货申请</title> <script type="text/javascript"> function countTotalRealPrice(){ var productNeedNum = $("#productNeedNum").val(); var realPrice= $("#realPrice").val(); var totalRealPrice=productNeedNum*realPrice; $("#totalRealPrice").val(totalRealPrice);
} function countTotalTicketPrice(){ var productNeedNum = $("#productNeedNum").val(); var ticketPrice = $("#ticketPrice").val() var totalTicketPrice= productNeedNum*ticketPrice; $("#totalTicketPrice").val(totalTicketPrice); }
}); /* function sumNum(){ $("input[name=productNeedNum]").each(function(){ //alert($(this).attr("id"));//每一个的id var productNeedNum=$("#productNeedNum").attr("value") alert(productNeedNum); // var sum += productNeedNum; //alert("sum:"+sum); // $("#sum").val(sum); });
} */
function addRow(){ var x=document.getElementById('tb1').insertRow(3); var a=x.insertCell(0) var b=x.insertCell(1) var c=x.insertCell(2) var d=x.insertCell(3) var e=x.insertCell(4) var f=x.insertCell(5) var g=x.insertCell(6) var h=x.insertCell(7) var a1 = "<select id='productId' name='productId' style='width: 140px;height: 22px; text-align: center;'><c:forEach items='${productIdNames}' var='p'><option value='${p.productId }'>${p.commName }</option></c:forEach></select>"; var b1="<select id='typeName' name='typeName' style='width: 140px;height: 22px; text-align: center;'><c:forEach items='${typeInfos }' var='ti'><option value='${ti.typeId }'> ${ti.typeName }</option></c:forEach> </select>"; var c1 = "<select id='' name='' style='width: 70px;height: 22px; text-align: center;'><option value='0'> 盒</option><option value='1'> 瓶</option></select>"; var d1="<input onkeyup='sum(this.id)' name='productNeedNum' id='productNeedNum' type='text' style='width:89%;height: 18px' value='0' />"; var e1='<input onkeyup="sum(this.id)" name="realPrice" id="realPrice" type="text" style=" width:89%;height: 18px;" value="0"/>'; var f1='<input onkeyup="sum(this.id)" name="ticketPrice" id="ticketPrice" type="text" style=" width:91%;height: 18px;" value="0"/>'; var g1='<input name="totalRealPrice" id="totalRealPrice" type="text" style=" width:92%;height: 18px;" value="0" />'; var h1="<input name='totalTicketPrice' id='totalTicketPrice' type='text' style=' width:92.5%;height: 18px;' value='0' />"; a.innerHTML=a1 b.innerHTML=b1 c.innerHTML=c1 d.innerHTML=d1 e.innerHTML=e1 f.innerHTML=f1 g.innerHTML=g1 h.innerHTML=h1 } function deleteRow(){ var tab = document.getElementById('tb1'); if(tab.rows.length > 4) { tab.deleteRow(tab.rows.length-2); }else{ alertMsg.confirm("已经剩下最后一行,不能删除!"); } }
function sum(x){ var y=document.getElementById(x).value; if(isNaN(y)){ document.getElementById(x).value=0; } var num=document.getElementById("productNeedNum").value; var realPrice=document.getElementById("realPrice").value; var ticketPrice=document.getElementById("ticketPrice").value; var total=0; if(realPrice!=null){ total=num*realPrice; document.getElementById("totalRealPrice").value=total; } if(ticketPrice!=null){ total=num*ticketPrice; document.getElementById("totalTicketPrice").value=total; }