C
C
Cyber_bober2016-03-12 13:58:49
JavaScript
Cyber_bober, 2016-03-12 13:58:49

How to process a form without a click?

Hello, I'm registering in the application and I want the coordinates and address from the Google database to be entered into the fields when entering the address. Backend on Django.

Here is the form

<input class="form-control" id="address" type="text" >
<input type="submit" onclick="codeAddress(); return false; " class="btn btn-success" value="Отправить">


The handler is launched on click, but this does not suit me, because on click the full form should go for processing and entering into the database. Tell me, how can I call the handler while entering the address and substitute the value with the coordinates in the hidden input?

Handler

function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var addressOne = results[0].formatted_address;
        var addressTwo = results[0].address_components[2].long_name;
        var location = results[0].geometry.location;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark Hole, 2016-03-12
@Cyber_bober

keypress event I think is fine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question