Использование переменных GeoLocation в CFSET - PullRequest
0 голосов
/ 20 марта 2019

Я пытаюсь перехватить данные геолокации и вставить их в базу данных.

Приведенный ниже код является моей попыткой зафиксировать долготу и широту браузера и сохранить значения в двух полях формы.Проблема в том, что выходной код генерирует несколько экземпляров двух полей формы (то есть «долгота» и «долгота»).Вот снимок экрана одного набора этих полей, которые заполняются.Как мне заполнить остальные?

Screenshot of generated Form

Код формы:

<div class="table-responsive">
   <table class="table table-1" style="color:##000000">
      <tr>
         <td>Tree No</td>
         <td>Current Status</td>
         <td>Graft Successful</td>
         <td>NOT Grafted</td>
         <td>Graft unsuccessful</td>
         <td>Tree Died</td>
      </tr>
      <cfoutput query="rsTreeList" >
         <tr>
            <td>#TreeID#</td>
            <td>#Status#</td>
            <td>
               <form name="form1" method="post" action="Recon_Update_Logic1.cfm?ID=#TreeID#">
                  <img src="images/Icons/Success.jpg" width="25" height="25" alt=""/>
                  <input id="latitude" name="latitude" type="text" />
                  <input id="longitude" name="longitude" type="hidden" />
                  <input name="submit" type="submit" id="Submit" value="Graft Successful">
               </form>
            </td>
            <td>
               <form name="form1" method="post" action="Recon_Update_Logic2.cfm?ID=#TreeID#">
                  <img src="images/Icons/NotGrafted.jpg" width="25" height="25" alt=""/>
                  <input id="latitude" name="latitude" type="text" />
                  <input id="longitude" name="longitude" type="hidden" />
                  <input name="submit" type="submit" id="Submit" value="NOT Grafted">
               </form>
            </td>
            <td>
               <form name="form1" method="post" action="Recon_Update_Logic3.cfm?ID=#TreeID#">
                  <img src="images/Icons/GraftUnsuccessful.jpg" width="25" height="25" alt=""/>
                  <input id="latitude" name="latitude" type="hidden" />
                  <input id="longitude" name="longitude" type="hidden" />
                  <input name="submit" type="submit" id="Submit" value="Graft Unsuccessful">
               </form>
            </td>
            <td>
               <form name="form1" method="post" action="Recon_Update_Logic4.cfm?ID=#TreeID#">
                  <img src="images/Icons/TreeDead.jpg" width="25" height="25" alt=""/>
                  <input id="latitude" name="latitude" type="hidden" />
                  <input id="longitude" name="longitude" type="hidden" />
                  <input name="submit" type="submit" id="Submit" value="Tree Dead">
               </form>
            </td>
         </tr>
      </cfoutput>
   </table>
</div>

Следующий код пытаетсядля заполнения всех элементов "широта" и "долгота":

<cfloop index="i" from="1" to="#rsTreeList.recordCount#">   
    <script>

    function getLocation()
    {
        if (navigator.geolocation)
        {
            navigator.geolocation.getCurrentPosition(showPosition);
        }
    }

    function showPosition(position)
    {
        document.getElementById("latitude").value = position.coords.latitude; 
        document.getElementByID("longitude").value = position.coords.longitude; 
    }
    getLocation();
   </script>
</cfloop>
...