gpt4 book ai didi

php - 如何不在 GET 查询中发送空输入值

转载 作者:行者123 更新时间:2023-12-01 06:19:00 25 4
gpt4 key购买 nike

我有一个这样的表格

<form action="index.php" method="get">
<input type="hidden" name="id" value="1">
<input type="hidden" name="order_by" value="">
<button type="submit">Submit</button>
</form>

它有一些 jQuery 处理程序来填充“order_by”字段。如果我提交此表单时填写了空的“order_by”,我会得到如下地址:index.php?id=1&order_by=

如果“order_by”为空,在提交表单后获取以下地址的最佳方法是什么:index.php?id=1

最佳答案

您可以禁用空字段,这样它们就不会添加为数据

$('form').submit(function(e){
var emptyinputs = $(this).find('input').filter(function(){
return !$.trim(this.value).length; // get all empty fields
}).prop('disabled',true);
});

关于php - 如何不在 GET 查询中发送空输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25790517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com