【发布时间】:2020-09-03 15:07:45
【问题描述】:
我正在尝试使用 PHP cURL 在 url 上填写和提交表单,但是,他们没有使用带有提交按钮的常规 form 标签。相反,他们只有一个带有 onclick 的 div 来提交在 input 字段中输入的值,该字段没有 name,但确实有一个 id 和一个 onChange 事件。
您可以在here 中看到它。 (您可以搜索“5458-011”进行测试。)
如何在input 字段中输入值并通过 cURL 提交?
以下是该网址的代码。
HTML:
<input onChange="mirrorSearch2()" list="addresses2"class="Header-Search-field" id="addressInputSmall" placeholder="Search by address, parcel or planning application number, or click on the map"/>
<datalist id="addresses2"></datalist>
<div onclick="runSearch(document.getElementById('addressInputSmall').value,'','addressInputSmall')" class="fa fa-search fa-2x" aria-hidden="true" id="Search-icon2"></div>
Javascript / jQuery:
//onChange
function mirrorSearch2() {
var thenew=$('#addressInputSmall').val()
//console.log(thenew);
$('#addressInput').val(thenew);
}
function mirrorSearch() {
var thenew=$('#addressInput').val()
//console.log(thenew);
$('#addressInputSmall').val(thenew);
}
//onClick
function runSearch(theAddress,theType,theID) {
//Now run a second query to get the geometry, if no geometry is found then send to old PIM search functionality (e.g. PPTS non-parcel records)
//console.log("RunSearch: "+theAddress)
if (theID=="addressInput") {
//console.log($('#addresses').children().length)
if ($('#addresses').children().length==1 ) {
//if there is only one option and they hit enter, then get the option value rather than search for the incomplete text.
//e.g. if they typed 1650 miss and hit enter, then send the 1650 MISSION ST from the option list.
$("#addresses").prop("selectedIndex", 0);
if ($( "#addresses option:first" ).val()) {
setTimeout('throttleSubmit($( "#addresses option:first" ).val());',400)
return
//theAddress = $( "#addresses option:first" ).val();
}
}
}
if (theID=="addressInputSmall") {
//console.log($('#addresses2').children().length)
if ($('#addresses2').children().length==1 ) {
//if there is only one option and they hit enter, then get the option value rather than search for the incomplete text.
//e.g. if they typed 1650 miss and hit enter, then send the 1650 MISSION ST from the option list.
$("#addresses2").prop("selectedIndex", 0);
if ($( "#addresses2 option:first" ).val()) {
setTimeout('throttleSubmit($( "#addresses2 option:first" ).val());',0)
return
//theAddress = $( "#addresses2 option:first" ).val();
}
}
}
//setTimeout('console.log($( "#addresses2 option:first" ).val())',100)
//console.log(theAddress)
throttleSubmit(theAddress)
}
【问题讨论】:
标签: javascript php html jquery curl