开发者

Add regular button inside form that does not perform a submit

开发者 https://www.devze.com 2023-03-18 22:36 出处:网络
I have this form declaration: <form method=\"post\" action=\"/web_services/buscar_vuelos?method=get\">

I have this form declaration:

<form method="post" action="/web_services/buscar_vuelos?method=get">
  <div id="addSegment_wrapper">
    <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="addTr" style="display: inline;">
      <span class="ui-button-text">Add Segment</span>
    </button>
  </div>
  <input id="web_services_submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-          text-only" type="submit" value="Search" name="commit">
</form>

And, altho开发者_运维知识库ugh I didn't specify "addSegment_wrapper" button as a submit one, every time I click on it, it calls the form action. I just want to treat this button as a regular one.

What should I do?


You could do

<button type="button">Add Segment</button>


Do this:

<button type="button" class="(rest of your classes)">Rest of your code</button>


Closer to Occams razor (for complex schemes*) could be to construct the 'form to be submitted' separately, ie, to not (ie, drop the use of) the "form" tag: for a description of the latter, please see "how to ajax post a form that includes fields in a dynamic table for which both rows and columns can be added dynamically"


* eg, when your form consists of multiple interaction-events, where a subset is used for form-submission.

0

精彩评论

暂无评论...
验证码 换一张
取 消