2013-02-11 280 views
-1

運行以下腳本時出現錯誤「請使用POST請求」。我只是一個初學者的HTML和JavaScript。任何人都可以在這裏幫助解決問題。請使用POST請求

的JavaScript

    function submitform(){ 
     if (!document.getElementById('reschedule').onclick) { 
      alert("reschedule") 
     } 
     if (!document.getElementById('home').onclick) { 
      alert("home") 
     } 
     if (!document.getElementById('cancel').onclick) { 
      alert("cancel") 
     } 
    } 

和HTML是

<html> 
    <form name="myform" method="post,get" onsubmit="return submitform();"> 
<input type="submit" id="reschedule" value="reschedule" /> 
<input type="submit" id="home" value="home" /> 
<input type="submit" id="cancel" value="cancel" /> 
</form> 

+2

的'method'屬性應該是* *或者 「POST」 或 「GET」;不是都。 – Pointy 2013-02-11 15:14:08

+0

您在提交表單後綁定了'onclick'事件。無論如何你都不需要點擊事件。 – AlienWebguy 2013-02-11 15:28:53

回答

6
<form name="myform" method="post" onsubmit="return submitform();"> 
2

改變這一點:

method="post,get" 

此:

method="post" 

<form>標籤屬性

+0

我試圖改變,並在jsfiddle中運行它..但這次得到不同的錯誤。 {「error」:「Shell表單不驗證{'html_initial_name':u'initial-js_lib','form':,'html_name':'js_lib','label': u'js lib','field':,'help_text':'','name':'js_lib'}「} – user2058205 2013-02-11 15:16:10

+0

您應該在問題中添加」django「然後。對不起,我不是django專家。 – TheBronx 2013-02-11 15:19:34

+1

您需要從'input'標籤中刪除'type =「submit」'。 – 2013-02-11 15:19:45