How to jump to select box 2 onChange of Select Box 1 using jquery -


i have 2 select boxes below.

<select class="box1">    <option>1</option>   <option>2</option>   <option>3</option>  </select>  <select class="box2">    <option>1</option>   <option>2</option>   <option>3</option>  </select> 

now after selecting item in slelect box 1 select box 2 should open automatically.

my code below.

<html> <head>    <link rel="stylesheet" type="text/css" href="jquery.editable-select.css">   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>   <script type="text/javascript" src="jquery.editable-select.pack.js"></script>    <script type="text/javascript">   $(function() {     $('.editable-select').editableselect(       {         bg_iframe: true,         onselect: function(list_item) {           $('#results').html('list item text: '+ list_item.text() +'<br> \           input value: '+ this.text.val());         }       }     );     var select = $('.editable-select:first');     var instances = select.editableselectinstances();     instances[0].addoption('germany, value added programmatically');   });   if(!window.console || !window.console.log || !$.browser.mozilla) {     window.console = {};     window.console.log = function(str) { $('#debug').show().val($('#debug').val() + str +'\n'); };   }   var hidden_offset;   function movehidden() {     var hidden = $('#hidden');     hidden.show();     $('#toggle_hidden').val('hide');     if(!hidden_offset) {       hidden_offset = hidden.offset();       hidden         .css('position', 'absolute')         .css('top', hidden_offset.top)         .css('left', hidden_offset.left)         .animate({top: 100, left: 400})       ;     } else {       hidden.animate({top: hidden_offset.top, left: hidden_offset.left}, function() {         hidden.css('position', 'static');         hidden_offset = null;       });     }   }   function togglehidden(btn) {     var hidden = $('#hidden');     if($('#hidden').is(':visible')) {       hidden.hide();       $(btn).val('display');     } else {       hidden.show();       $(btn).val('hide');     }   }    $(document).ready(function(){   $("#country1").change(function(){     $("#country").focus();   });     });   </script>    <style type="text/css">   .example .example-select {     padding-top: 10px;     padding-bottom: 10px;     border-bottom: 1px dotted #ccc;   }   .example p {     margin: 0;     padding: 0;   }   .last {     margin-bottom: 10px;   }   #comment-form {     width: 100%;   }   </style>   </head> <body>   <div id="container">  <form name="form">         <select name="country" id="country1" class="editable-select">           <option>denmark</option>           <option selected="selected">sweden, selected</option>           <option>norway</option>            <option>finland</option>           <option>iceland</option>         </select>          <select name="state" id="country" class="editable-select" style="width:200px;">           <option>denmark</option>            <option>norway</option>            <option>finland</option>           <option>iceland</option>         </select> </form>   </body> </html> 

i have used onchage , onfocus functions. didnt result.

the div tag <div id="container"> has no closing tag.

the code:

$(document).ready(function(){       $("#country1").change(function(){         $("#country").focus();           });     }); 

should work correctly test on jsfiddle.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -