admin管理员组文章数量:1405194
I have a select field within a form:
<form id="myform">
<select id="value" onchange="javascript: document.myform.submit()">
<option>....
</select>
</form>
After the form is submitted, it is impossible to use the 'back' button without resubmitting the form. However, if I use a regular 'submit' button, it is possible.
Is there a way you know of to get this behavior while still being able to use the javascript 'submit()'?
Accessibility is not a concern, having javascript enabled is required to use this site and that is the way the client wants it.
I have a select field within a form:
<form id="myform">
<select id="value" onchange="javascript: document.myform.submit()">
<option>....
</select>
</form>
After the form is submitted, it is impossible to use the 'back' button without resubmitting the form. However, if I use a regular 'submit' button, it is possible.
Is there a way you know of to get this behavior while still being able to use the javascript 'submit()'?
Accessibility is not a concern, having javascript enabled is required to use this site and that is the way the client wants it.
Share Improve this question asked Mar 6, 2009 at 14:18 user35288user35288 4- This sounds very browser-specific. What are you trying to acplish? Maybe there is a different approach that will help solve your problem. – jonstjohn Commented Mar 6, 2009 at 14:23
- I say this again and again and again, be careful with onchange selects: stackoverflow./questions/580281/… – Dan Lew Commented Mar 6, 2009 at 14:24
- It's for the iPhone, so IE doesn't matter. – user35288 Commented Mar 6, 2009 at 16:47
- Ok it goes back without re-sending the form, but the onchange="function()" only works the first time...is there any way to re-set that? – user35288 Commented Mar 6, 2009 at 16:48
2 Answers
Reset to default 2Call a function instead.
<select id="value" onchange="sendForm()">
...script block...
function sendForm() {
document.myform.submit()
}
Also, you never need to specify javascript:
outside of an HREF
tag.
"onchange only works first time?"
Are you re-selecting the same value? onchange only fires when there is a change. If you want to be able to reselect the same option, you need to use onblur.
Also you really should be using
document.getElementById("myform").submit();
本文标签: htmlonchangequotjavascript documentmyformsubmit()quot vs normal submitStack Overflow
版权声明:本文标题:html - onchange="javascript: document.my_form.submit()" vs. normal submit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744872997a2629742.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论