一个比较有趣的例子

<script language="javascript">
 function Qty_onClick(arg)
 {
  var theObj = document.getElementById("Qty")
  var amount = theObj.value;
  if(isNaN(parseInt(amount))){amount=0};
  if (amount<=0)//the MinAmount
  {
   alert("已达到最小数值0");//MinAmountReached
   theObj.value = 0+1; //the MinAmount+1
   theObj.focus();
   return;
  }//end if
  if (amount>=100)//the MaxAmount
  {
   alert("已达到最大数值100");//MaxAmountReached
   theObj.value = 100-1; //the MaxAmount-1
   theObj.focus();
   return;
  }//end if
  var sum = parseInt(amount) + parseInt(arg);
  if (sum > 0 && sum < 100)
  {
   theObj.value = sum;
  }//end if
 }
 </script>
<table border="0" cellspacing="0" cellpadding="0" style="border:1px solid #CCCCCC;">
<tr>
<td rowspan="3" style="border-right:1px solid #CCCCCC;">
        <input name="Qty" type="text" id="Qty" style="font-family:'Verdana';font-size:12px;text-align:right;border:none;" value='1' size=2 maxlength=2>
       </td>
       <td style="line-height:9px;">
        <a style="font-family: Webdings;font-size: 9px;line-height: 8px;text-decoration: none;" href="javascript:;" onClick="javascript:Qty_onClick(1);"><font face="Webdings">5</font></a>
       </td>
     </tr>
     <tr>
       <td height="1" bgcolor="#CCCCCC"></td>
     </tr>
     <tr>
       <td style="line-height:9px;">
        <a style="font-family: Webdings;font-size: 9px;line-height: 8px;text-decoration: none;" href="javascript:;" onClick="javascript:Qty_onClick(-1);"><font face="Webdings">6</font></a>
       </td>
     </tr>
</table>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值