嘿,我正在制作一个网站,您可以向其他用户发送电子邮件。
我的问题是当我去提交时,它没有提交两个值?
我的表单有一个文本框,用户想要在其中发送电子邮件,另一个是文本区域,即消息。
而且我不想要 2 个提交按钮
看看 http://www.w3.org/TR/html401/interact/forms.html#h-17.1 如何创建表单。
您的输入需要唯一的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>
要
发送到服务器的任何值,请确保它位于表单标记中。当用户单击您的"提交"按钮时,表单中的所有数据都会与页面请求一起发送。您可以在表单中包含任意数量的项目。
<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
"继续。您可以提交多个表单元素,只要它们具有不同的名称属性并且位于表单标签中即可。
到目前为止,我发现的最好的就在这里
快乐编码
检查您的input
并添加唯一的name
属性。