admin管理员组文章数量:1429977
I have My request parameters in the URL of current page. When I click on submit in the same page, parameters lost got lost in the new request. How to retain the request parameters even after submitting the form?
I have My request parameters in the URL of current page. When I click on submit in the same page, parameters lost got lost in the new request. How to retain the request parameters even after submitting the form?
Share Improve this question asked Jul 28, 2011 at 4:21 galaxy3galaxy3 612 silver badges3 bronze badges4 Answers
Reset to default 2You can read the query params from the url and add them as a hidden fields into the form you are submitting. This will send the query string params along with the form.
- Send the request parameters as form's GET params
- Have the server set the parameters in a cookie so it is available in every page.
- Put it in browser's local storage.
If submitting the form via POST, you can include request parameters in the form's action
attribute, eg
<form method="post" action="action?id=123&foo=bar">
<input type="text" name="baz">
<input type="submit">
</form>
What you are asking for is state management. It can be done in several ways
- HttpSession
- Cookies
- Hidden fields
- URL rewriting.
Hidden fields is an easy way to do it; although the HTML can get more lengthy. I personally prefer HttpSession.
本文标签: javascriptHow to set request parameters when you clicking on submitStack Overflow
版权声明:本文标题:javascript - How to set request parameters when you clicking on submit? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745534583a2662213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论