我的按钮坏了
My button didnt work
嗨,我创建了一个登录表单,但当我点击登录时,我无法将用户名和密码发送到数据库,代码为:
CCD_ 1。
我可以发送用户名并通过这个代码:
<input id="enterbutton" type="submit" value="Login">
现在这个按钮看起来很难看,因为我在css中添加了这个按钮的图片。有了这个第一个代码按钮,看起来正是我想要的样子。如何解决这个问题?我的表单外观:
<form name="forma2" action="login.php" method="post">
<br>
<input class="inputbox" type="text" name="username" maxlength="18" placeholder="username">
<br>
<br>
<input class="inputbox" type="password" name="password" placeholder="password">
<br>
<input type="submit" value="Login">
</form>
工作,但没有css。
如果您想使用:
<a id="enter" href="#"><div id = "enterbutton">enter</"div></a>
因为你已经应用了一个特定的css,所以只需执行.即可
$('#enter').on('click', function(){
$('#form').submit();
});
只需记住在表单中添加一个id即可。
如果您想使用button
作为div
,您应该在JavaScript中声明.click()
事件如何:
$('#enter').on('click', function(){
$('#form[name="forma2"]').submit();
});
您可以使用锚点提交表单,但您将使用事件处理程序:
<form id='myForm' name="forma2" action="login.php" method="post">
<br>
<input class="inputbox" type="text" name="username" maxlength="18" placeholder="username">
<br>
<br>
<input class="inputbox" type="password" name="password" placeholder="password">
<br>
<a id="enter" href="#" onclick='document.getElementById("myForm").submit()'><div id = "enterbutton">enter</div></a>
</form>
<form name="forma2" action="login.php" method="post" id="myForm">
<br>
<input class="inputbox" type="text" name="username" maxlength="18" placeholder="username">
<br>
<br>
<input class="inputbox" type="password" name="password" placeholder="password">
<br>
<a href="javascript:void(0);" onclick="submitMe();">Submit</a>
</form>
<script>
function submitMe() {
document.getElementById("myForm").submit();
}
</script>
@Grimbode的回答很好。但我不喜欢添加更多的脚本,您可能也没有jQuery。我们只能用CSS处理它。你的<a>
的问题是你没有为此添加任何处理程序,所以无论何时你点击这个<a>
,它都不会做任何事情。<input type="submit">
代表形式,它处理的正是我们想要的。但通常,input
带有一些默认的CSS,我不喜欢它,你也不喜欢。
你可以在这里找到我的样品:https://jsfiddle.net/y7mvu9zn/
相关文章:
- "工具提示"jQuery插件坏了
- 我的按钮坏了
- 节点JS:时间机器坏了——timekeeper.travel不做时间旅行
- HTML/JavaScript:为什么不'我的纽扣坏了
- 我的素数函数坏了,但我没有;我不知道为什么
- Uglifier是不是弄坏了我的睡衣
- 我升级了Knockout.js,现在我的模板坏了
- 为什么范围$手表坏了
- 所有的javascript都 ajax.aspnetcdn.com/ajax/ 坏了?打破所有外部引用?自周五以来
- 使用 SignalR 查明是否有人在另一个网站上按下了按钮
- 角度控制器功能坏了
- 检测是否附加了按钮单击事件
- 谷歌可视化图表API示例坏了,如何修复它们
- 将Facebook应用程序移动到新服务器,现在它坏了
- 为什么我的代码坏了
- 野生动物园浏览器中的后退按钮坏了
- 砌体坏了(可能是经典)
- 检查是否在Javascript中单击了按钮
- 旋转相机后,Three.js的skybox似乎坏了
- 烬:后退按钮坏了