admin管理员组文章数量:1323342
I want to send a value with a link in a submit form. The form method is post and I like to keep it that way, otherwise my problem would have been pretty easy using something like "?myvale=1".
So this code illustrates what I wan't:
<a href="#" name="submit value="1" onclick="document.editDelete.submit()" class="button icon edit">Test</a>
How can I acplish what I want with javascript or something like that?
I want to send a value with a link in a submit form. The form method is post and I like to keep it that way, otherwise my problem would have been pretty easy using something like "?myvale=1".
So this code illustrates what I wan't:
<a href="#" name="submit value="1" onclick="document.editDelete.submit()" class="button icon edit">Test</a>
How can I acplish what I want with javascript or something like that?
Share Improve this question edited Dec 9, 2011 at 21:53 Abbas 6,8864 gold badges37 silver badges49 bronze badges asked Dec 9, 2011 at 21:37 FredrikFredrik 6356 gold badges14 silver badges28 bronze badges 1-
1
The
name
attribute of your markup seems to be incorrect. It seems to be missing the closing double-quote. – MilkyWayJoe Commented Dec 9, 2011 at 21:41
5 Answers
Reset to default 4Why not set a hidden form value in a submit handler?
<form ...>
<input type="hidden" name="theParam"/>
...
<a href="#" ... onclick="handler()">Test</a>
function handler() {
document.editDelete.theParam.value = "the value";
document.editDelete.submit();
}
(Adjust names/etc. to match your HTML.)
Add a hidden form field and set its value in your onclick
handler, just before submitting.
Why not use a hidden input and onsubmit
set the input value to whatever you want to send.
Yup, Hidden form value would do it.
<input type="hidden" name="your_input" value="1"/>
Then just submit your form as you want to.
at the form tag the action attribute attribute="/page?myvale=1" and keep the the method get .you will receive a get query string + the posted data
本文标签: javascriptSend value with submit link in a formStack Overflow
版权声明:本文标题:javascript - Send value with submit link in a form - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742135573a2422352.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论