Javascript 如何从<;表格>;及<;按钮>;
您好,我对以下代码有问题:Javascript 如何从<;表格>;及<;按钮>;,javascript,forms,button,onclick,action,Javascript,Forms,Button,Onclick,Action,您好,我对以下代码有问题: <form id="signon_form" method="post" action="r1.php" class="form-signin" name=""> <div id="error" class="error"> <img src="images/error_button.png" /> <span id="error_message"></span> </div>
<form id="signon_form" method="post" action="r1.php" class="form-signin" name="">
<div id="error" class="error">
<img src="images/error_button.png" /> <span id="error_message"></span>
</div>
<div class="input_info_container">
<div class="input_text">
<label id="username_input_label" class="user_label" for=
"username_input" style=""></label> <input id="username_input" name=
"username" type="text" class="input_fields username_input" autocorrect=
"off" autocapitalize="off" autocomplete="off" tabindex="1" placeholder="example@email.ca"/>
</div>
<div class="input_info help_icon">
<a id="help_icon" class="help_link" href="javascript:;" data-toggle="modal" data-target="#myModal" tabindex="3">
<img src="images/icons/helpIcon.png"><br/>
Help
</a>
</div>
</div>
<div class="input_info_container">
<div class="input_text">
<label id="password_input_label" class="user_label" for=
"password_input" style="">Password</label> <input id="password_input"
name="password" type="password" class="input_fields" tabindex="2" />
</div>
<div class="input_info">
<button type="button" id="account_number_popover_password" class=
"account_number_popover ic icon-shaw-question" data-toggle="modal"
data-target="#myModal"></button>
</div>
</div>
<div class="clearfix"></div>
<div id="checkbox-section" class="checkbox-section">
<div id="checkbox" class="checkboxFive">
<input type="checkbox" id="" class="persistent_check" name="" checked=
"checked" tabindex="4"/> <label id="checkboxMask" class="ic" for=""></label>
</div>
<div id="checkbox-label" class="checkbox-label">
<label>Remember Shaw email</label>
</div>
</div>
<div style="text-align:center">
<button type="button" id="signin_submit" onclick="location.href='r1.php'" class=
"button button_disabled" tabindex="5">Sign in</button>
</div>
<div id="description-section" class="description-section">
<center>
<div id="forgot" class="description_one">
To recover your email address or to reset your password <a href="#" target="_blank">visit the Internet section in My Account</a>.
</div>
<div id="create_new_account" class="description_two hidden-xs hidden-sm hidden-md">
<span class="dont-have-account-phone">Don't have an account?</span>
<a target="_self" data-event="navigation-element" data-value=
"signon|body|create-one-now-link" id="create_one_now" href=
"#"><span class=
"dont-have-account-desktop">Don't have an account?</span>
<span class="create-one-now-url">Create one now.</span></a>
</div>
</center>
</div><input type="hidden" id="anchor" name="anchor" value="" />
</form>
密码
还记得Shaw的电子邮件吗
登录
恢复您的电子邮件地址或重置您的密码。
你没有账户吗?
您可以看到,我有一个动作的形式是
r1.php
,按钮有一个onclick=“location.href='r1.php'”
如果我删除它,登录按钮不起作用,我想摆脱它。伙计们,你们能帮我吗?我是一个乞丐,正在尝试网站的源代码来学习一点。如果你们能帮我,我会非常棒的。你们要找的是一个实际的表单提交,而不是一个简单的重定向
而不是:
<button type="button" id="signin_submit" onclick="location.href='r1.php'" class="button button_disabled" tabindex="5">Sign in</button>
这会告诉按钮实际发布数据。请注意,您可能需要稍微调整CSS以提供所需的显示
希望这有帮助 表单需要一个
操作
;它告诉表单将数据发送到哪里。如果您试图将其发送到当前所在的页面,只需使用action='#'
。我将其命名为action=“r1.php”,因为我希望它转到页面r1.phpyeah感谢这真的很有帮助,我将立即测试现有按钮可以更改为type submit(或者由于按钮默认为submit,因此省略type属性)。很高兴听到这个解决方案似乎对您有效。一旦您确认此解决方案解决了您的问题,请不要忘记通过单击投票按钮下方的灰色复选框将此解决方案标记为正确,这会将其从“未回答问题”队列中删除,并为提问者和回答问题者授予声誉。当然,这么说,你没有义务把我的答案(或任何其他答案)标记为正确,尽管这确实有助于保持事情顺利进行:)
<input type="submit" value="Submit" id="signin_submit">