tags:

views:

40

answers:

2

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">
<input 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&amp;o=0&amp;st=all&amp;find=#!/search/ while i want it to submit to http://domain.com/#!/search/?q=f&amp;o=0&amp;st=all&amp;find= how can id that

A: 

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>
tilman
but i want to to #!/search/ while if i am on http://domain.com/directory it submits it here
Web Worm
You asked how to submit a form to itself. Thats how you do it. Thanks for downvote.
tilman
David Dorward
+2  A: 

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.

David Dorward