Created
January 16, 2020 22:26
-
-
Save phpfiddle/96fd10bdfdc394d88f47de8403bb19c4 to your computer and use it in GitHub Desktop.
[ Posted by Erik ] autocomplete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> | |
<script src="https://code.jquery.com/jquery-1.10.2.js"></script> | |
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> | |
<script src="https://www.skbl.nl/wp-content/plugins/locaties/includes/kbl_filter.js"></script> | |
<?php | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
// collect value of input field | |
$name = $_POST['naam']; | |
if (empty($name)) { | |
echo "Name is empty"; | |
} else { | |
echo $name; | |
} | |
} | |
?> | |
<form class="skbl-form" name="filterform" id="filterform" method="post" action=""> | |
<div class="col-md-5"> | |
<input type="text" name="naam" id="naam" value='' size="40" class="" placeholder="4-cijferige postcode, plaatsnaam, provincie of naam locatie"> | |
</div> | |
<input type="text" id="result" value=''></div> | |
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | |
<input type="submit" onchange="SubmitForm('filterform');" value="zoek" class=""> | |
</form> | |
</body> | |
</html> | |
<script> | |
$(function() { | |
var pad = ['Option 1', 'Option 2']; | |
$( "#naam" ).autocomplete({ | |
source: pad, | |
autoSelectFirst: true, | |
autoFocus: true, | |
minLength:2, | |
select: function (event, ui) { | |
var v = ui.item.value; | |
var wijk = ui.item.wijk; | |
var woonplaats = ui.item.woonplaats; | |
var lat = ui.item.lat; | |
var lon = ui.item.lon; | |
var postcode = ui.item.postcode; | |
var soort = ui.item.soort; | |
var kbl_id = ui.item.kbl_id; | |
$('#result').val(v); | |
$('#result').html(v); | |
$('#MessageTo').html("Value is" + v + " Lat is " + lat + " Lon is " + lon + " wijk is " + wijk); | |
$('#Hidden1').html("Something else here" + v); | |
$('#wijk').val(wijk); | |
$('#woonplaats').val(woonplaats); | |
$('#soort').val(soort); | |
$('#kbl_id').val(kbl_id); | |
$('#lat').val(lat); | |
$('#lon').val(lon); | |
//currentValue = ui.item.value; | |
$('#postcode').val(postcode); | |
// update what is displayed in the textbox | |
this.value = v; | |
// hiermee wordt form gesubmit na aanklikken | |
//$(this).closest('form#filterform').trigger('submit'); | |
// $('#naam').val(ui.item.label); | |
// $('form#filterform').submit(); } | |
return false; | |
} | |
}); | |
}); | |
function SubmitForm(formId) { | |
var oForm = document.getElementById(formId); | |
if (oForm) { | |
alert("DEBUG - could not find element " + formId); | |
$('#naam').val(v); | |
$('#naam').html(v); | |
oForm.submit(); | |
} | |
else { | |
alert("DEBUG - could not find element " + formId); | |
} | |
} | |
function selectAllText(textbox) { | |
textbox.focus(); | |
textbox.select(); | |
$("#map").insertBefore("#page-slide"); | |
//$("#map").prependTo("#page-slide"); | |
$("#page-slide").hide(); | |
} | |
jQuery('.input').keypress(function (e) { // submit als enter wordt ingedrukt bij input field | |
if (e.which == 13) { | |
$('form#filterform').submit(); | |
return false; //<---- Add this line | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment