<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>207页阶段二</title> </head> <body> <form name="formA" method="post" action=""> <table bgcolor="#999999" border="1"> <tr> <td colspan="5"><center><b><font size="+2">简易购物车</font></b></center></td> </tr> <tr> <td>商品名称</td> <td>数量(件)</td> <td>单价(美元)</td> <td>运费(美元)</td> <td><input name="btnCalc" type="button" value="合计" onclick="Calc()" /></td> </tr> <tr> <td>跑跑道具</td> <td><input name="txtNum" type="text" /></td> <td><input name="txtPrice" type="text" /></td> <td><input name="txtRdPrice" type="text" /></td> <td><input name="AllResult" type="text" />美元</td> </tr> </table> </form> <script language="javascript"> function Calc(){ if(document.formA.txtNum.value == ""){ document.formA.txtNum.value = "数量不能为空"; return; } if(document.formA.txtPrice.value == ""){ document.formA.txtPrice.value = "单价不能为空"; return; } if(document.formA.txtRdPrice.value == ""){ document.formA.txtRdPrice.value = "运费不能为空"; return; } document.formA.AllResult.value = parseFloat(document.formA.txtNum.value) * parseFloat(document.formA.txtPrice.value) + parseFloat(document.formA.txtRdPrice.value); } </script> </body> </html>
