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:

  1. there button create button dynamically
  2. when user click button form displayed
  3. 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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -