开发者

show data at DIV after use .focus() in jquery

Lets say i have a form like:

<select id="model"/>
<input type="text" id="serial"/>
<label>Packing <div id="packing" name="packing"></div></label>
<br/>
<input id="pack1" type="radio" class="pack" name="pack" value="OK" />OK
<input id="pack2" type="radio" class="pack" name="pack" value="NG" />NG
i'm using barcode scanner for input `serial`, i want do like this:
  1. choose model at dropdown list
  2. after model choosen, set focus into #serial so it can makes data show at textfield
  3. data after scan show inside textfield
  4. after textfield are filled, show some data from DB inside the DIV

this is what i have got:

$("#model").click(function() {
          var data=$("#model").val();
          $("submit input:text.eq(0)").focus();
          var str=data;
          var matches=str.match(/[TEJUG2]\D*D/i);

          $.ajax({
                   type:"post",
                   url:"process1.php",
                   data:"packing="+matches+"&action=packcond",
                   cache:false,
                   async:false,
                   success: function(res){
                                    $('#value').replaceWith(
                                          "<div id='value'><h6>" + res + "</h6></div>"
                                          );
                                    }
                   });
          });

b开发者_如何学Gout i think this not resolve the problem.can you help me? :-)


$("#model").change(function() {
                  $('#serial').focus();
                  });

$('#serial').change(function(){
                  var data=$("#model").val();
                  var str=data;
                  var matches=str.match(/[TEJUG2]\D*D/i);

                  $.ajax({
                          type:"post",
                          url:"process1.php",
                          data:"packing="+matches+"&action=packcond",
                          cache:false,
                          async:false,
                          success: function(res){
                                          $('#value').replaceWith(
                                          "<div id='value'><h6>" + res + "</h6></div>"
                                          );
                                      }
                          });
                  });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜