Javascript 如何向url添加搜索参数
有一个表格可以过滤和显示轮胎。它使用数据库中的数据:汽车型号、汽车年份等。结果显示在表格下。我想要的是将结果放在url中,以便在过滤器中使用它Javascript 如何向url添加搜索参数,javascript,jquery,html,url,url-parameters,Javascript,Jquery,Html,Url,Url Parameters,有一个表格可以过滤和显示轮胎。它使用数据库中的数据:汽车型号、汽车年份等。结果显示在表格下。我想要的是将结果放在url中,以便在过滤器中使用它 <form id="select_form" action="/" method="POST"> <label>Производитель:</label> <select id="category1" name="vendor"> <?php echo $opt->ShowC
<form id="select_form" action="/" method="POST">
<label>Производитель:</label>
<select id="category1" name="vendor">
<?php echo $opt->ShowCategory(podbor_shini_i_diski); ?>
</select>
<label>Марка:</label>
<select id="type1" name="car">
<option value="0">Выбрать...</option>
</select>
<label>Год выпуска:</label>
<select id="year1" name="year">
<option value="0">Выбрать...</option>
</select>
<label>Модификация:</label>
<select id="modification1" name="mod">
<option value="0">Выбрать...</option>
</select>
<input id="sendForm" type="submit" class="button" value="Подтвердить" />
</form>
<div id="result"></div>
Производитель:
Марка:
Выбрать...
Год выпуска:
Выбрать...
Модификация:
Выбрать...
还有一个jquery
jQuery(function($) {
var table = "podbor_shini_i_diski";
var show = "3";
$("select#type1").attr("disabled", "disabled");
$("select#year1").attr("disabled", "disabled");
$("select#modification1").attr("disabled", "disabled");
$("select#category1").change(function() {
$("select#type1").attr("disabled", "disabled");
$("select#type1").html("<option>Ждите...</option>");
var vendor = $("select#category1 option:selected").attr('value');
$.post("/auto-parts/select_type.php", {
vendor: vendor,
table: table
}, function(data) {
$("select#type1").removeAttr("disabled");
$("select#type1").html(data);
});
});
$("select#type1").change(function() {
$("select#year1").attr("disabled", "disabled");
$("select#year1").html("<option>Ждите...</option>");
var vendor = $("select#category1 option:selected").attr('value');
var car = $("select#type1 option:selected").attr('value');
$.post("/auto-parts/select_year.php", {
vendor: vendor,
car: car,
table: table
}, function(data) {
$("select#year1").removeAttr("disabled");
$("select#year1").html(data);
});
});
$("select#year1").change(function() {
$("select#modification1").attr("disabled", "disabled");
$("select#modification1").html("<option>Ждите...</option>");
var vendor = $("select#category1 option:selected").attr('value');
var car = $("select#type1 option:selected").attr('value');
var year = $("select#year1 option:selected").attr('value');
$.post("/auto-parts/show_modification.php", {
vendor: vendor,
car: car,
year: year,
table: table
}, function(data) {
$("select#modification1").removeAttr("disabled");
$("select#modification1").html(data);
});
});
$("form#select_form").submit(function() {
var vendor = $("select#category1 option:selected").attr('value');
var car = $("select#type1 option:selected").attr('value');
var year = $("select#year1 option:selected").attr('value');
var mod = $("select#modification1 option:selected").attr('value');
$.post("/auto-parts/shini_show.php", {
vendor: vendor,
car: car,
year: year,
mod: mod,
table: table,
show: show
},
function(data) {
$("#result").html(data);
});
return false;
});
});
jQuery(函数($){
var table=“podbor_shini_i_diski”;
var show=“3”;
$(“选择类型1”).attr(“禁用”、“禁用”);
$(“select#year1”).attr(“disabled”、“disabled”);
$(“选择修改1”).attr(“禁用”、“禁用”);
$(“选择#类别1”).change(函数(){
$(“选择类型1”).attr(“禁用”、“禁用”);
$(“select#type1”).html(“ЖЖцццц…”);
var vendor=$(“选择#类别1选项:选定”).attr('value');
$.post(“/auto parts/select_type.php”{
供应商:供应商,
表:表
},函数(数据){
$(“选择类型1”).removeAttr(“禁用”);
$(“选择类型1”).html(数据);
});
});
$(“选择类型1”).change(函数(){
$(“select#year1”).attr(“disabled”、“disabled”);
$(“select#year1”).html(“ЖЖцццц…”);
var vendor=$(“选择#类别1选项:选定”).attr('value');
var car=$(“选择#类型1选项:选中”).attr('value');
$.post(“/auto parts/select_year.php”{
供应商:供应商,
车:车,
表:表
},函数(数据){
$(“选择年份1”).removeAttr(“禁用”);
$(“选择#年份1”).html(数据);
});
});
$(“选择#年份1”)。更改(函数(){
$(“选择修改1”).attr(“禁用”、“禁用”);
$(“选择修改1”).html(“ЖЖццццц…”);
var vendor=$(“选择#类别1选项:选定”).attr('value');
var car=$(“选择#类型1选项:选中”).attr('value');
var year=$(“选择#year1选项:选中”).attr('value');
$.post(“/auto parts/show_modification.php”{
供应商:供应商,
车:车,
年份:年份,,
表:表
},函数(数据){
$(“选择修改1”).removeAttr(“禁用”);
$(“选择#修改1”).html(数据);
});
});
$(“表单#选择表单”)。提交(函数(){
var vendor=$(“选择#类别1选项:选定”).attr('value');
var car=$(“选择#类型1选项:选中”).attr('value');
var year=$(“选择#year1选项:选中”).attr('value');
var mod=$(“选择#修改1选项:选中”).attr('value');
$.post(“/auto parts/shini_show.php”{
供应商:供应商,
车:车,
年份:年份,,
mod:mod,
表:表,,
秀:秀
},
功能(数据){
$(“#结果”).html(数据);
});
返回false;
});
});
代码的那部分呢
if ($zavod_shini != "") {
echo "<TR><TD><h3>Заводская комплектация</h3></TD></TR>\r\n";
$zavod_shini_ = explode('|', $zavod_shini);
for ($j = 0; $j <= count($zavod_shini_); $j++) {
$zav_width_[$j] = substr($zavod_shini_[$j], 0, 3);
$zav_height_[$j] = substr($zavod_shini_[$j], 4, 2);
$zav_diam_[$j] = substr($zavod_shini_[$j], 8, 2);
if ($zavod_shini_[$j] != "")
echo "<TR><TD><a href='../?pa_shirina-profilya=$zav_width_[$j]&pa_vysota-profilya=$zav_height_[$j]&pa_diameter=$zav_diam_[$j]'>".$zavod_shini_[$j].
"</a></TD></TR>\r\n";
}
}
if($zavod_shini!=“”){
回声“аааааааааааааааа;
$zavod_shini_=爆炸('124;',$zavod_shini);
对于($j=0;$j请这样尝试
$.get("/auto-parts/shini_show.php?vendor=vendor&car=car&year=year&mod=mod&table=table&show=show",
function(data) {
$("#result").html(data);
});
你是这个意思吗?如果你想把搜索参数添加到URL。只需将表单方法POST更改为GET