gpt4 book ai didi

javascript - 按下回车键时表单未提交

转载 作者:行者123 更新时间:2023-12-02 14:09:49 24 4
gpt4 key购买 nike

当我按下搜索按钮时,我得到了很好的结果。但是当我按下 Enter 键时,我也希望能够进行搜索。

问题是当我按 Enter 键时,它只会重新加载该位置并转到 displaylist()。我怎样才能做到这一点?

我有以下代码 html 和 JS。

HTML

<div class="input-group">
<span class="input-group-btn">
<button id="basic-search" class="btn btn-default " type="button" > <span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
</span>
<input type="text" id="basicsearchVal" class="form-control" placeholder="Enter a Ticker Symbol,CERT, BHCor a fragment of a Bank Name,." autocomplete="on">

</div>

JS

$(document).ready(function () {

var newURL;
var SearchData;
var detailPageUrl ="summary.html";
var mydata;

displaylist(detailPageUrl,mydata,newURL);

$("#basicsearchVal").keydown(function(e) {
if (this.value != '') {
console.log( "this.value keydown " +this.value);
$(".search-result").jqGrid('GridUnload');
var searchInput = $("#basicsearchVal").val()
$("#pageTitle").html("Search Result(s) for <span class='text-primary'>" +searchInput+ "</span>")
$( "#watchlist-b").remove();
$("#watchList-b1").remove();
$("#watchList-b2").remove();
SearchData =newURL +"/services-monitor/GetQuickSearch?searchString="+searchInput;
console.log("SearchData " +SearchData);
displaySearchResult(detailPageUrl,SearchData,mydata);

jQuery(".search-result").trigger("reloadGrid");

} else {
console.log( "Please enter a Name to search" +this.value);
}
});





});

最佳答案

在按钮标记中将按钮类型更改为“提交”。

关于javascript - 按下回车键时表单未提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39714508/

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