2017-03-20 21 views
-2

我想傳遞一個變量,但爲此我需要創建一個窗體。但我使用JavaScript來打開下一頁(這是一個塊頁面),但我想直接在按鈕中傳遞method="post",而不是在表單中,因爲它不能識別代碼。這裏有一個例子:傳遞方法=「發佈」按鈕,而不是形式

我有什麼:

<form action="" method="post"> 
<button onclick="document.getElementById('id144').style.display='block'" class="btn btn-warning">Editar nome grupo</button> 
</form> 

我想要什麼:

<button //pass method = post here onclick="document.getElementById('id144').style.display='block'" class="btn btn-warning">Editar nome grupo</button> 
+0

'

+0

*「但我想直接在按鈕」* - 你不能。按鈕不使用方法;期。儘管如此,你可以觸發一個函數 –

+2

*「因爲它不承認代碼」* - 抱歉,但您的問題太不明確,太寬泛。無論如何,你的答案都在下面。看到了。這就是我在評論中所說的,但是你忽略了他們或者留下了這個問題。 –

回答

1
<form action="" id="formname" method="post"> 

</form>  
<button onclick="document.getElementById('formname').submit();document.getElementById('id144').style.display='block';" class="btn btn-warning">Editar nome grupo</button> 

設置形式ID。

相關問題