Php “提交”按钮仅作为指向锚点的链接使用
我有以下代码:Php “提交”按钮仅作为指向锚点的链接使用,php,html,cross-browser,Php,Html,Cross Browser,我有以下代码: <form enctype="multipart/form-data" id="search_form" name="search_form" action="thisfile.php#anchorname" method="get"> <!-- Lots of search fields here --> <input name="search" type="submit" value="Search" /> </form>
<form enctype="multipart/form-data" id="search_form" name="search_form" action="thisfile.php#anchorname" method="get">
<!-- Lots of search fields here -->
<input name="search" type="submit" value="Search" />
</form>
<?php if (isset($_GET['search'])) {
// Search in database
?>
<div id="anchorname">
<!-- Table with results here -->
</div>
<?php
}
如果这对任何人都有用,下面是我使用JQuery所做的:
$(function() {
// ...
<?php if (isset($_GET['search'])) { ?>
var target = $("#anchorname");
$('html,body').animate({
scrollTop: target.offset().top
}, 500);
<?php } ?>
});
$(函数(){
// ...
var目标=$(“#anchorname”);
$('html,body')。设置动画({
scrollTop:target.offset().top
}, 500);
});
代替div锚定,尝试
并将div环绕在其周围,不要命名,或将其命名为其他名称。使用%23
在表单操作中对哈希进行编码尝试两者都不起作用。请使用POST方法,尤其是因为您使用了多部分/表单数据
编码。谢谢!我已经删除了enctype=“multipart/form data”
,现在使用的是客户端方法。但我仍然感到困惑:为什么可以提交但不能重新提交?