2011-12-26 136 views
0

在以下HTML表单中,我无法派生用户名。是因为使用“ID”而不是“NAME”?建议解决这个问题的替代方案。HTML电子邮件表格错误

<form action="mailto:[email protected]" method="post" enctype="text/pain"> 
    Username:<input type="text" id="usr"/> 
    Password:<input type="password" name="pwd"/> 
    <input type="submit"/> 
    </form> 

回答

4

是因为使用的不是 “名称”, “ID” 的?

是。来自manual

控件的“控件名称”由其名称属性给出。 FORM元素中控件的name属性的范围是FORM元素。

改为使用name属性。

+0

好吧那好... – sandbox 2011-12-26 11:19:11

0

来访问值,你应该使用names,修改您的代码是这样的:

<form action="mailto:[email protected]" method="post" enctype="text/pain"> 
    Username:<input type="text" name="usr"/> 
    Password:<input type="password" name="pwd"/> 
    <input type="submit"/> 
</form> 

,然后你可以通过usrpwd变量访问这些值。

希望这会有所帮助。