php - Search Form Error sends to ?q= -


i'm using bootstrap theme , form this:

<form class="navbar-form" role="search" method="get" action="<?=$domain?>search" onsubmit="dosubmit();">     <div class="input-group">         <input type="text" class="form-control input" placeholder="search" name="q">         <div class="input-group-btn">             <button  type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>         </div>     </div> </form> 

the original page placed

http://www.domain.com/toys/search/electronics kids/

when search form "test" , press enter, sends me

http://www.domain.com/toys/search/?q=test

with should replace code send me to:

http://www.domain.com/toys/search/test

thanks in advance!

i assume use jquery if use bootstrap.

so following:

html:

<form class="navbar-form" role="search" method="get" action="<?=$domain?>search" id="searchfrom">     <div class="input-group">         <input type="text" id="searchfield" class="form-control input" placeholder="search" name="q">         <div class="input-group-btn">             <button  type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>         </div>     </div> </form> 

js:

$('body').on('submit','#searchfrom', function(e) {     e.preventdefault();     location.href = $(this).attr('action')+'/'+encodeuricomponent($('#searchfield').val()); }); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -