php - load data into html select when users press create button -
i have problem while loading data html select when users press or click button. here scenario:
- there button create button dynamically
- when user click button form displayed
- when form displayed there html select dynamically showing data database using php server side.
does know how solve scenario number 3?
i have used jquery create new form load data html select painful me.
php
something this:
<?php $option[] = array('option1'=>'somepage1', 'option2'=>'somepage2', 'option3'=>'somepage3'); echo json_encode(array('options'=>$option)) //set output json encode ?> js
$(document).ready(function(){ $("#create").bind('click',function(){ $.get('somepage.php',function(data){ $("#form").show(); //form holder $("#select").empty(); $.each(data.options, function(i,val){ $("#select").append("<option>"+val.option1+"</option>" +"<option>"+val.option2+"</option>" +"<option>"+val.option3+"</option>"); }); },'json'); $(this).unbind(); }); });
Comments
Post a Comment