Note that there are some explanatory texts on larger screens.

plurals
  1. POFilling the input of <form> with existing value
    primarykey
    data
    text
    <p>I've got a small issue. I've got a following form:</p> <pre><code>&lt;form action="task.php" method="post"&gt; ID: &lt;input id="iddev" type="text" name="id" disabled&gt; &lt;br/&gt; Latitude: &lt;input type="text" name="lat"&gt; &lt;br/&gt; Longitude: &lt;input type="text" name="lon"&gt; &lt;br/&gt; &lt;button type="submit" class="btn btn-danger"&gt;Done!&lt;/button&gt; &lt;/form&gt; </code></pre> <p>I would like to fill a disabled "id input" with an existing value that I have stored in my dropdown:</p> <pre><code>&lt;? foreach ($arajka as $a){ echo "&lt;option data-id='" .$a['id'] ."' data-lat='" .$a['lat'] . "' data-lon='" .$a['lon'] . "'value=\"" .$a['id']. "\"&gt;" .$a['id']. "_" . $a['name'] . "&lt;/option&gt;"; } ?&gt; </code></pre> <p>I mean I want this input to change as user selects other option from my dropdown menu. I'm already changing some stuff with JQuery:</p> <pre><code>$( document ).ready(function() { $('#loc').change(function(){ var lat = $(this).find(':selected').attr('data-lat'); var lon = $(this).find(':selected').attr('data-lon'); var id = $(this).find(':selected').attr('data-id'); $('#mapka').html("&lt;iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"https://maps.google.com/maps?q=loc:"+lat+","+lon+"&amp;amp;num=1&amp;amp;t=m&amp;amp;z=14&amp;amp;output=embed\"&gt;&lt;/iframe&gt;&lt;br /&gt;"); $('#iddev').html(id); }); }); </code></pre> <p>Is there any option to do that? Am I missing something really simple? Or do I have to reload whole form? Kind regards!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload