One form, several buttons for sending and sending links

Possible duplicate:
Several submit buttons in HTML form

I have a web form with several submit buttons. To determine which button was pressed, each has its own name, for example:

<input type="submit" name="foo" value="Foo Foo">

There are also regular links on the form that act as submit buttons, for example:

<a href="" onclick="parentNode.submit();return false;">
Bar
</a>

How can I also distinguish links used as submit buttons?



I'm not sure if this is relevant:
Here is the beginning of the form

<form action="foobar" method="post" enctype="multipart/form-data">

I use Flask (a Werkzeug-based micro framework) that uses Python (2.6 in this case).

+3
source share
5 answers

, , ? , , , .

/ , , - :

<input type="hidden" id="submitClicked" />
<input type="submit" onclick="javascript:document.getElementById('submitClicked').value='linkName';return true;" id="linkName">Submit</input>

. , , .

+3

submitSource , , onclick . .

+1

, : <ìnput type="submit"> " ", , CSS, .

: () , , () .

+1

RedFilter - , , , :

( "" ), , , . , , .

"command" , :

<a href="" onclick="parentNode.action += "?command=bar"; parentNode.submit(); return false;">

, , :

<a href="" onclick="parentNode.action += "?bar=bar+bar"; parentNode.submit(); return false;">

, , POST, GET ( ), , , . , Java ServletRequest#getParameter , GET, POST, . , , .

0

I would recommend instead of onclick="parentNode.submit();return false;"creating a js function that all links call to execute the send. Then you can use a hidden field or get a variable or something else to pass the link identifier.

function submitMe(linkID)
{
    document.getElementById("hfWhichButtonSubmittedMe").value = linkID;
    document.getElementById(linkID).parentNode.submit();
    return false;
}

...

<a href="" id="mySubmitLink1" onclick="return submitMe('mySubmitLink1');">blah blah</a>
0
source

Source: https://habr.com/ru/post/1765634/


All Articles