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
Add a ment  | 

5 Answers 5

Reset to default 4

Why 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