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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -