2017-09-11 71 views
-2

我有php搜索过滤器页面,其中我使用不同的字段..其中一个是年龄最年轻的驱动程序字段有2个值,如21-24和25+ ..基本上,我只想保持选择的值在选择即使在搜索后,所以用户知道他搜索的是什么..现在发生什么,当我从现场选择25+,然后点击搜索它可以回到21-24。但随着网页连接顶部数据库,因此它选择从数据库,我进入如数据库下面的截图请检查并让我知道,如果有任何解决方案如何根据选择框值更改页面的URL?

<select class="half" id="form_frame" name="" onsubmit="getData(this);"/> 
    <option id="value1" value="21-24" selected="selected">21-24</option> 
    <option id="value2" value="25+">25+</option> 
    </select> 

当我slect从外地SELCT 25的所有值的值从驾驶员年龄字段+则URL是

http://localhost/Vehicle2/?car_type=0&pickup=0&return=0&residence_two=International&driver_age=25%2B&passengers=No.+of+Passengers&search=

http://localhost/Vehicle2/?car_type=0&pickup=0&return=0&residence_two=International&driver_age=21-24&passengers=No.+of+Passengers&search=

我想driverage的= 21-24,而不是driver_age

+0

请把完整的表格代码。 –

+0

@Ankit Solanki你需要从我这里?你想看完整的代码 –

+0

只需填写表格代码。 –

回答

0

应用在JavaScript onchange事件类似如下如果你正在使用jQuery

jQuery(function() { 
     jQuery("#form_frame").change(function() { 
      var id = jQuery(this).val();; 
      location.href = "http://localhost/php-page/option"+id+"="+id 

     }) 
    }) 
0

简单利用变化的事件处理程序选择框

$(document).on('change','#form_frame',function(){ 
 

 
//window.location.href="http://localhost/php-//page/option"+$(this).//val()+"="$(this).val(); 
 

 
console.log("http://localhost/phppage/option"+$(this).val()+"="+$(this).val()); 
 

 

 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<select class="half" id="form_frame" name=""> 
 
<option value="10" selected="selected">10</option> 
 
<option value="11">11</option> 
 
</select>