Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script type="text/javascript">
- function appendOption(select,option) {
- try {
- selectBox.add(option,null); // Standards compliant.
- } catch (e) {
- selectBox.add(option); // IE only version.
- }
- }
- function loadOptions() {
- // Simulate an AJAX request that will call the
- // loadOptionsCallback function after 500ms.
- setTimeout(loadOptionsCallback,500);
- }
- function loadOptionsCallback() {
- var selectBox = document.getElementById('selectBox');
- var option = document.createElement('option');
- option.text = 'new option';
- appendOption(selectBox,option);
- }
- </script>
- </head>
- <body>
- <select id="selectBox" onmousedown="loadOptions();">
- <option>Any</option>
- </select>
- </body>
- </html>
- $(function() {
- jQuery(".selectBox").live("focus", function() {
- loadOptions();
- });
- });
- <html>
- <head>
- <script src="jquery-latest.js" type="text/javascript"/>
- </head>
- <body>
- <select id="selectBox" onmousedown="loadOptions();">
- <option>Any</option>
- </select>
- <script type="text/javascript">
- $(function() {
- jQuery(".selectBox").live("focus", function() {
- loadOptions();
- });
- });
- function appendOption(select, option) {
- try {
- selectBox.add(option, null); // Standards compliant.
- } catch (e) {
- selectBox.add(option); // IE only version.
- }
- }
- function loadOptions() {
- // Simulate an AJAX request that will call the
- // loadOptionsCallback function after 500ms.
- setTimeout(loadOptionsCallback, 500);
- }
- function loadOptionsCallback() {
- var selectBox = document.getElementById('selectBox');
- var option = document.createElement('option');
- option.text = 'new option';
- appendOption(selectBox, option);
- }
- </script>
- </body>
Add Comment
Please, Sign In to add comment