开发者

how can i submit form to hash or self

开发者 https://www.devze.com 2023-01-17 10:32 出处:网络
i have the following form <form action=\"#!/search/\" method=\"get\" style=\"display:inline;\" id=\"hdr_q\">

i have the following form

<form action="#!/search/" method="get" style="display:inline;" id="hdr_q">                      
<table cellpadding="0" cellspacing="0">
<tr><td><input id="f_peoples" name="q" class="sb_box" size="40" autocomplete="off">
<input type="hidden" value="0" name="o">
<input type="hidden" value="all" name="st">
</td><td>&nbsp;</td><td width="20px" valign="middle">
<inp开发者_JAVA技巧ut type="submit" id="sfind" name="find" value="Search"></td></tr></table>
</form>

when i hit search button it goes to http://domain.com/?q=f&o=0&st=all&find=#!/search/ while i want it to submit to http://domain.com/#!/search/?q=f&o=0&st=all&find= how can id that


As far as a form is concerned, it makes no sense to "submit" data to a fragment identifier — that is never sent to the server. The query string always comes before the fragment identifier.

If you want to achieve this, you'll need to build the URI using JavaScript and not using standard form submission techniques. Most general purpose JS libraries come with routines to serialise form data to standard encoded data, this will get you most of the way there.


Set action="". An empty action sends the form to itself.

Also, do you really want to send the value of the submit button as well? May I suggest, take out the name="find" for the submit button.

If you want to have &find= at the end, add a hidden field with no value.

<form action="" method="get" style="display:inline;" id="hdr_q">
  <table cellpadding="0" cellspacing="0">
    <tr><td><input id="f_peoples" name="q" class="sb_box" size="40" autocomplete="off">
        <input type="hidden" value="0" name="o">
        <input type="hidden" value="all" name="st">
      </td><td>&nbsp;</td><td width="20px" valign="middle">
        <input type="hidden" id="find" name="find" value=""/>
        <input type="submit" id="sfind" value="Search"></td>
    </tr>
  </table>
</form>
0

精彩评论

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