Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="container">
- <div >
- <select id="person_country_id" onchange="on_value_chnage(value)">
- </select>
- </div>
- <script>
- valueSelected();
- </script>
- </div>
- // javascripts/dynamic_states.js.erb
- var states = new Array();
- states.push(new Array('dharmdip', 'dharmdip1', '1'));
- states.push(new Array('ankit', 'ankit1', '2'));
- states.push(new Array('dhaval', 'dhaval1', '3'));
- states.push(new Array('parth', 'parth1', '4'));
- states.push(new Array('zinda', 'zinda1', '5'));
- states.push(new Array('sagar', 'sagar1', '6'));
- function valueSelected() {
- states.each(function(state) {
- $('person_country_id').insert( '<option value='+state[1]+'|'+state[2]+'>'+state[0]+'</option>');
- });
- }
- function on_value_chnage(value)
- {alert(value);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement