javascript - Can JS be used to display a new dropdown already filled by php mysql? -
i know php server-side , js client side, i've done research haven't found looking for.
so i'd know if possible use javascript display php code?
scenario:
i have drop down list on page being updated database
(quick example)
php while($row...) { <option><?php echo $row["number"]; ?></option> }
and using javacript display new drop down list when button clicked
<script language="javascript"> var = 1; function changeit() { my_div.innerhtml = my_div.innerhtml +"<br><select><option name='mytext'+ i></option></select>" i++; } </script>
this works i'd able have new drop down list appear pre filled.
is possible have these 2 items work together?? if how? or require page reload each time since php loads before reaches user (and how again..)?
any or guidance appreciated.
this example uses jquery
make ajax call your-script.php
, in turn returns html select list:
$(document).ready(function() { // event handler click on button control $('#your-button').click(function() { // make ajax request $.ajax({ url:"your-script.php", success:function(e) { // insert html select control $('#control-panel').html(e); } }); }); }); <div id="control-panel">replace select control</div> <input type="button" id="your-button" />
here contents of your-script.php
file:
<?php print '<select><option value="1">1</option></select>'; ?>
Comments
Post a Comment