2011-05-20 151 views
0

嘿即時通訊製作一個網站,你可以發送其他用戶的電子郵件。如何僅使用一個提交按鈕提交兩個值?

我的問題是,當我去提交它不提交兩個值?

我的表單有一個文本框,用戶想要發送電子郵件,而另一個文本區域是消息。

,我不想2提交按鈕

+6

也許一些codez? – Albireo 2011-05-20 07:21:04

+0

他們是否在相同的形式?您只需要一個包含輸入框和文本區域的表單。 – GolezTrol 2011-05-20 07:21:14

+0

你可以發送無限的價值與一個提交按鈕,你會告訴我們的HTML/PHP代碼? – diEcho 2011-05-20 07:21:23

回答

0
<html> 
<head> 
/*... your code here 
...*/ 
</head> 
<body> 
<form name='sampleForm' action='sample.htm' onsubmit='ValidatethisForm()' method="post" enctype="multipart/form-data"> 
    <input type='text' name='formElem1'> 
    <textarea name='formElem2'></textarea> 
    <input type = 'submit' value='submit'> 
</form> 
</body> 

</html> 

在驗證功能。曾經完成你的驗證使用 「return true」 繼續。您可以提交多個表單元素,只要它們具有不同的名稱屬性,並且這些元素位於表單標記中即可。

+0

我完全困惑。驗證*或* javascript何時發揮作用?這個答案是如何得到的? – 2011-05-21 00:50:10

2

要發送到服務器的任何值都要確保它在窗體標記中。當用戶點擊你的「提交」按鈕時,表單中的所有數據與頁面請求一起被髮送出去。您可以在表單中包含儘可能多的項目。

4

您的輸入需要唯一的name屬性。

例子:

<form> 
<input type="text" name="recipient_address" /> 
<textarea name="message_body"></textarea> 

<!-- no real need for a name on the submit button --> 
<input type="submit" value="Send Message" /> 
</form> 
0

到目前爲止,最好的,我發現是here

編碼快樂