javascript - Populate Bootstrap form from Dropdown -
i trying populate bootstrap form content database. user flow is, user selects record dropdown has been filled information database. whenever select option dropdown fills form relevant data. here sample code:
<?php mysql_connect('server', 'name', 'password'); mysql_select_db('database'); $sql = "select * table"; $result = mysql_query($sql); echo "<select name='select' class='form-control'"; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['details_id'] . "'>" . $row['name'] . "</option>"; } echo "</select>"; ?> </div> <script> </script> </div> <legend>edit details , submit request</legend> <!-- text input--> <div class="form-group"> <label class="col-md-4 control-label" for="edit">name:</label> <div class="col-md-8"> <input id="edit" name="edit" type="text" class="form-control input-md"> </div> </div>
the dropdown being filled properly, don't know how fill form data now!
use ajax. wrote in previous post. add event listener select box, when item picked, can make ajax request php site data need. json_encode data (make array first), , jquery, can put data form.
Comments
Post a Comment