0

I am trying to set an "input text" with the value passed by a variable and I can not.

The html and js are below:

JS:

function clique_mapa(latlng) {        
    var value1_lat = $('#antena01_lat').val();
    var value1_log = $('#antena01_log').val();

    var value2_lat = $('#antena02_lat').val();
    var value2_log = $('#antena02_log').val();

    if (typeof value1_lat == 'undefined') {
        $('input[name=antena01_lat]').val(value1_lat);
        $('input[name=antena01_log]').val(value1_log);                        
    }
};

Html:

<div class="coluna menu">
    Latitude<br />
    <input type="text" name="antena01_lat"/> <br />
    Longitude<br />
    <input type="text" name="antena01_log"/> <br /><br />    

    <input type="button" id="clique_mapa" name="clique_mapa" value="Abrir mapa" />
</div>

tks

1
  • where is document ready? Commented Apr 14, 2013 at 0:14

2 Answers 2

2

You need to assign an id to your input

<input type="text" name="antena01_lat" id="antena01_lat"/>
Sign up to request clarification or add additional context in comments.

Comments

1

You have

if (typeof value1_lat == 'undefined')

Shouldn't this be

if (typeof value1_lat != 'undefined') 

1 Comment

the code passing through the point $('input[name=antena01_lat]').val(value1_lat);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.