php通过下拉列表过滤而不使用提交按钮
我设置了下面的代码。但是我如何在没有提交按钮的情况下过滤结果并根据下拉值(用户的 ID)过滤结果?
form method="post" name="report_filter" action="<?= $_SERVER['PHP_SELF'];?>" >
select name="name" onchange="report_filter.submit();">
<option value="--">Filter by:</option>
<option value="1">Andi</option>
<option value="2">Katy</option>
<option value="3">Max</option>
<select>
PHP //
<? if(isset($_POST['submit'])):
$mem->StaffTodayFilterSummary($_GET('value'));
else :
$mem->StaffToday();
endif;
?>
</form>
ive got the code below set up. but how do i filter the result without submit button and filtering the result based on dropdown value (id for user)?
form method="post" name="report_filter" action="<?= $_SERVER['PHP_SELF'];?>" >
select name="name" onchange="report_filter.submit();">
<option value="--">Filter by:</option>
<option value="1">Andi</option>
<option value="2">Katy</option>
<option value="3">Max</option>
<select>
PHP //
<? if(isset($_POST['submit'])):
$mem->StaffTodayFilterSummary($_GET('value'));
else :
$mem->StaffToday();
endif;
?>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
name="report_filter"
更改为id="report_filter"
。然后将您的
onchange
事件更改为onchange="document.getElementById('report_filter').submit()"
这是完整的代码:
我更改了
isset()
检查POST['name']
并将过滤器摘要设置为传入$_POST['name']
。我不知道$_GET('value')
试图从哪里获取任何内容,但除非它位于 URL 中,否则我不知道它是如何工作的。You need to change
name="report_filter"
toid="report_filter"
.Then change your
onchange
event to sayonchange="document.getElementById('report_filter').submit()"
Here's the full code:
I changed
isset()
to checkPOST['name']
and set the filter summary to pass in$_POST['name']
as well. I don't know where$_GET('value')
was trying to get anything from but unless it's in the URL I don't see how it would work.