4.29

来源:互联网 发布:中国历年贸易顺差数据 编辑:程序博客网 时间:2024/05/18 01:10

今天老师讲了javaScript,做了一个竞拍页面,代码如下

 

 

<!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>
<SCRIPT LANGUAGE = "JavaScript">
function calcu()
{
var numb1= document.calc.num1.value;
var numb2= document.calc.num2.value;
if ((numb1!="") && (numb2!=""))
{
if (parseFloat(numb1)<0)
  {
    alert("竞拍价格不能小于零!/n请重填");
    return; //函数返回,不再执行后面的代码
  }
   if (parseFloat(numb2)<0)
  {
    alert("购买数量不能小于零!/n请重填");
    return;
  }
 var total= parseFloat(numb1)*parseFloat(numb2);
 document.calc.result.value=total;
 if ((total>500) &&(total<=1000))
  alert("购买总价超过500/n支付时将赠送超级Q币2枚!");
 if ((total>1000) &&(total<=2000))
  alert("购买总价超过1000/n支付时将赠送IBM光电智能鼠标1只!");
 if ((total>2000))
  alert("购买总价超过2000/n请直接与贵宾台联系!");
 }
else
    alert("购买数量或竞拍价格没有填写/n请重新输入!");
}
</SCRIPT>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>竞拍</title>
<style type="text/css">
<!--
#Layer1 {
    position:absolute;
    left:119px;
    top:113px;
    width:491px;
    height:535px;
    z-index:1;
}
.STYLE1 {
    font-family: "宋体";
    font-size: x-large;
}
.STYLE2 {font-size: x-large}
-->
</style>
</head>

<body>
<div id="Layer1">
  <div align="center">
    <p class="STYLE1">我的竞拍</p>
   
    <label></label>
   
    <label></label>
      <p class="STYLE1"><img src="截图26.jpg" width="453" height="357" alt="DEll" /></p>
      <form name ="calc">
      <p class="STYLE1">DELL笔记本</p>
      <p class="STYLE1">物品单价
        <input type="text" name="num1" />
      </p>
      <span class="STYLE2">物品数量</span>
      <input type="text" name="num2" /><br />
   
  
      <span class="STYLE2">预付金额</span>
        <input type="text" name="result" /><br />
     
   
   
    <div align="center">
        <input name="result1" type="button" value="计算看看"onclick="calcu()" />
          <input type="reset" name="Submit" value="归0" />
      </form>
    </div>
    <p align="left">&nbsp;</p>
  </div>
</div>
<p align="center" class="STYLE1">&nbsp;</p>
</body>
</html>

原创粉丝点击