How to get input values and concatenate Javascript

2

I'm doing this, but it's not working

var nomeRua = document.getElementById('nomeRua').value();
var nomeBairro = document.getElementById('nomeBairro').value();
var uf = document.getElementById('uf').value();
var nomeCidade = document.getElementById('nomeCidade').value();
geocoder.geocode({ 'address': endereco + nomeRua + ", " + nomeBairro + ", " + uf + ", " + nomeCidade }, function (results, status) {

(...)
    
asked by anonymous 20.01.2016 / 22:15

1 answer

5

What you are looking for is the .value attribute and not a method like .val(); of jQuery or getValue(); of other libraries.

Changing this should resolve. By the way, a suggestion for this concatenation becomes more readable:

var geoCode = [endereco + nomeRua, nomeBairro, uf, nomeCidade].join(', ');
geocoder.geocode({ 'address': geoCode }, function (results, status) {
    
20.01.2016 / 22:27