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:
- choose
model
at dropdown list - after
model
choosen, set focus into#serial
so it can makes data show at textfield - data after scan show inside textfield
- 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>"
);
}
});
});
精彩评论