Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
I need to insert a value in an input field of an html form through javascript

HTML code

<div id="formulario">
    <h1>Posicionamento de CEO</h1>
    <form method="POST" style="width: 500px;">   

<div class="form-group">
   <label class="control-label  " for="id_identification">Identificação</label>
        
<div class=" ">enter code here
   <input type="text" name="identification" maxlength="256" class=" form-control" required="" id="id_identification">
</div>
</div>
<div class="form-group">
   <label class="control-label  " for="id_geolocation">Geolocalização</label>
       <div class=" ">
            <input type="text" name="geolocation" maxlength="100" class=" form-control" required="" id="id_geolocation">
</div
        <button type="button" onclick="start()" class="botao">Clique aqui para carregar 
         mapa</button>
    </form>
</div>

Javascript code that opens the map and captures the coordinate when I click on the map.

async function sendCoordsToMyApi(evt) {
    const coords = {
      lat: evt.latLng.lat(),
      lng: evt.latLng.lng()
    };

    console.log("vou enviar as coordenadas para api:", coords);
    alert(JSON.stringify(coords));

I need to enter the coordinate of the constant coords in the form in the input field id="id_geolocation" can you help me?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use document.getElementById to get the element you are trying to add text to

coords = ...;
document.getElementById("id_geolocation").value = JSON.stringify(coords);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!