js

<script>

function spec_sub(count){
  var d = document.getElementsByName('radio');
  for(var i=0;i<d.length;i++){
   if(d[i].checked == true){
    document.form1.defaultSpec.value = d[i].value;
   }
  }
 regexpdat=/^/d+$/;
 for(var i=0;i<count;i++){
  var num=document.getElementById('num'+i);
  var openPrice=document.getElementById('openPrice'+i);
  var price=document.getElementById('price'+i);
  if(parseFloat(price.value)>parseFloat(openPrice.value)){
     alert('本店價格不能大於市場價格');
     return false;
  }
  if(!regexpdat.test(num.value)||num.value==0){
      alert('庫存應爲正整數');
   return false;
  }
 }
 document.form1.action='product.shtml?method=submitProductSpec';
 document.form1.submit();
 return false;
}
</script> 

<form name="form1" method="post" action="product.shtml?method=submitProductSpec">

 <table width="763" border="0" cellpadding="0" cellspacing="0">

    #set($count = 0)
    #foreach($pspec in $specList)
    <tr>        
      <td class="zhright6"><input type='text' size='5' id='openPrice$!count'  name='spec_${pspec.id}_openPrice' value='$!{number.format('0.00',$!pspec.openPrice)}' />
      </td><!--市場價格-->
      <td class="zhright6"><input type='text' size='5' id='price$!count' name='spec_${pspec.id}_price' value='$!{number.format('0.00',$!pspec.price)}' /></td>
      <td class="zhright6"><input type='text' size='5' id='num$!count' name='spec_${pspec.id}_num' value='$!{pspec.num}' /></td><!--庫存-->
      <td class="zhright6"><a href="#" οnclick="spec_add(${pspec.id});return false;">複製</a> | <a href="#" οnclick="spec_del(${pspec.id});return false;">刪除</a></td>
    </tr>
   #set($count = 1 + $count)
   <tr>
    <td colspan="9"><img src="images/zhright_xian.jpg" /></td>
   </tr>
    #end

</table>
       <td align="left" width="68" height="18"><input type="button" class="products_set" value="保 存" οnclick="spec_sub($count);return false;" #if($count == 0) disabled #end></td>
</form>

發佈了21 篇原創文章 · 獲贊 4 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章