【发布时间】:2026-01-08 01:55:02
【问题描述】:
我有 2 个表格,用于存储来自 SKYTV 和 NOWTV 的电影 ID、海报和运行时间。他们持有身份证号码和海报路径。单击 NOWTV 复选框时,将显示 NOWTV 电影。单击 SkyTV 时,将显示 SKYTV 电影。
我还有一个范围滑块,它表示最大运行时间。
我有 2 个页面(见下文)- submit.php 和 ajax.html
问题:
在 HTML 页面上,有一个滑块。当用户移动滑块时,我希望这代表返回时允许的最大运行时间的变化。运行时存储在两个表中。
ajax.html 中的滑块是:
<script>
var slider = document.getElementById("runtime");
var output = document.getElementById("runtime_");
output.innerHTML = slider.value;
slider.oninput = function() {
output.innerHTML = this.value;
}
</script>
滑块如下:
<div class="slidecontainer">
<input type="range" min="1" max="360" value="120" class="slider" id="runtime">
<p>Runtime: <span id="runtime_"></span></p>
这是 ajax.html 中的脚本,它创建表并返回要发送到 submit.php 的 HTML 值。请原谅函数说“员工”,我正在学习教程。
<script>
function makeTable(data){
var tbl_body = "";
for (var i = 0; i < data.length; i++) {
var tbl_row = "";
var t = i;
for (var j=0; j<2; j++) {
//tbl_row +=("<td>" + data[i].tmdbid + "</td>");
tbl_row +=("<td><IMG SRC='my link goes here"+ data[i].poster +"'></td>");
i++;
}
tbl_body += "<tr>"+tbl_row+"</tr>"
}
return tbl_body;
}
function getEmployeeFilterOptions(){
var opts = [];
$checkboxes.each(function(){
if(this.checked){
opts.push(this.name);
}
});
var slider = document.getElementById("runtime");
opts.push(slider.value);
return opts;
}
function updateEmployees(opts){
$.ajax({
type: "POST",
url: "submit.php",
dataType : 'json',
cache: false,
data: {
filterOpts: opts
},
success: function(records){
$('#employees tbody').html(makeTable(records));
}
});
}
var $checkboxes = $("input:checkbox");
$checkboxes.on("change", function(){
var opts = getEmployeeFilterOptions();
updateEmployees(opts);
});
updateEmployees();
</script>
我的提交页面然后根据返回创建 SQL,用于我当前拥有的滑块:
if (in_array("runtime", $opts)) {
$where .= ' AND runtime < VALUE OF THE SLIDER?????';
}
预期结果是滑块的移动会改变 SQL 返回的 WHERE 运行时
【问题讨论】: