I dont' know if anybody is willing to help me out on a bit on Javascript? I am working on a Webapp with Flask.
To get the user info and a googlemaps load I have to use pure Javascript.
This is what I got for my onClick event
and it works just fine.
// Google Map initialize
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: { lat: 47.2172500, lng: -1.5533600 }
});
document.getElementById('submit').addEventListener('click', function () {
var userQuestion = document.getElementById('userQuestion').value;
requestQuestionMap( map, userQuestion);
});
}
Now I also would like that if the user hits the "enter" key that my function works the same way (sending the user search to my API). I tried some solutions but none seem to work for me. I am probably getting something wrong!
my field for user search in HTML is a classic "input" like this:
<form>
<input type="text" name="question" id="userQuestion" required>
<input type="button" value="Dit moi tout ! " id="submit">
</form>
Of course I did some research here and on google and tried out some solution. none of them seem to fit.
question from:
https://stackoverflow.com/questions/65844646/integration-of-eventlistner-in-javascript-not-working 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…