开发者

Weird form submit with id or name of submit btn as querystring?

simple normal form tha开发者_开发百科t's submitting an action.

<form id="myAppSearchForm" method="get" action="<%= search_path %>">
    <fieldset>
        <div class="input-inside-label">
            <label for="myAppSearchForm_searchstring">Search weavr</label>
            <input id="myAppSearchForm_searchstring" name="search" class="search" title="enter search term" />
        </div>
        <button class="btn" name="myAppSearchFormSubmit" type="submit">GO</button>
    </fieldset>
</form>

however I don't get why the ID or name attribute of the Submitbutton gets added to the query string?

Like so: myurl/search?search=test&myAppSearchFormSubmit=

Any idea why that could happen?


That's just how forms work. Drop the name attribute and the value of that button won't be included in the params for the form submission.


Change it to an <input type="submit" name="myAppSearchFormSubmit"> and it should show up. <button> tags are really a form element, though they show up the same as an <input type="button"> for the most part, so they don't really have any affect on a form.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜