有一个表格可以过滤和显示轮胎。它使用来自数据库的数据:汽车型号,汽车年份等。结果显示在表格下。我想要的是将结果放在url中,以便在过滤器中使用它。
<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;
});
});
还有部分代码
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";
}
}
问题是我不知道如何使用ajax将结果中的参数添加到url
答案 0 :(得分:0)
尝试这样
$.get("/auto-parts/shini_show.php?vendor=vendor&car=car&year=year&mod=mod&table=table&show=show",
function(data) {
$("#result").html(data);
});