方式1:
form action="/order/?act=order" method="post" name="rep1">
<div class="discount_info_l_inp"><input type="text" οnblur="if(this.value == '' ) this.value='請輸入優惠碼';" οnfοcus="if(this.value == '請輸入優惠碼' ) this.value='';" value="<{if $coupon_check}>該優惠碼不可用 請輸入新優惠碼<{elseif $coupon_over}>每份菜只能使用一次優惠券<{else}>請輸入優惠碼<{/if}>"
name="coupon_code"></div>
</form>
方式2:
form action="/order/?act=order" method="post" name="rep1">
<div class="discount_info_l_inp"><input type="text" οnblur="if(this.value == '' ) this.value='請輸入優惠碼';" οnfοcus="if(this.value == '請輸入優惠碼' ) this.value='';" value="<{if $coupon_check}>該優惠碼不可用 請輸入新優惠碼<{elseif $coupon_over}>每份菜只能使用一次優惠券<{else}>請輸入優惠碼<{/if}>" name="coupon_code"></div><div class="discount_info_r" ><a href="javascript:document.forms['rep1'].submit();" >確定</a></div>
</form>
最開始按照方式1通過js提交表單,表單正常提交,未報任何錯誤,如此提交數次後,火狐瀏覽器報錯 TypeError: document.reqForm1.submit is not a function .從網上搜索的答案來看,有些此類報錯是由於<input type="submit" name="submit" /> ,或者是html 元素name出現html關鍵字 ,所以報錯。但是上面代碼並沒有關鍵字問題,後來偶然發現js提交表單的正確格式是javascript:document.forms['rep1'].submit();
改成此種格式,報錯消失。