SHARE
TWEET

Untitled

a guest Jun 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div id="container">
  2.        
  3. <div >
  4.     <select id="person_country_id" onchange="on_value_chnage(value)">
  5.     </select>
  6. </div>
  7.  
  8. <script>
  9.     valueSelected();
  10.  
  11. </script>
  12.     </div>
  13.  
  14.  
  15.  
  16. // javascripts/dynamic_states.js.erb
  17. var states = new Array();
  18.   states.push(new Array('dharmdip', 'dharmdip1', '1'));
  19.   states.push(new Array('ankit', 'ankit1', '2'));
  20.   states.push(new Array('dhaval', 'dhaval1', '3'));
  21.   states.push(new Array('parth', 'parth1', '4'));
  22.   states.push(new Array('zinda', 'zinda1', '5'));
  23.   states.push(new Array('sagar', 'sagar1', '6'));
  24.  
  25. function valueSelected() {
  26.   states.each(function(state) {
  27.     $('person_country_id').insert( '<option value='+state[1]+'|'+state[2]+'>'+state[0]+'</option>');
  28.   });
  29. }
  30.  
  31. function on_value_chnage(value)
  32. {alert(value);
  33. }
RAW Paste Data
Top