显示使用后.focus在DIV数据()jQuery中 [英] show data at DIV after use .focus() in jquery
本文介绍了显示使用后.focus在DIV数据()jQuery中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以说我有一样的形式:
<选择一个id =模式/>
<输入类型=文本ID =串行/>
<标签>包装及LT; DIV ID =包装NAME =包装>< / DIV>< /标签>
< BR />
<输入ID =PACK1类型=无线电级=包装NAME =包的价值=OK/>确定
<输入ID =PACK2类型=无线电级=包装NAME =包的价值=NG/> NG
我使用的输入`serial`,我要像这样吧code扫描仪:
- 选择
模式
在下拉列表 - 在
模式
choosen,将焦点设置为#serial
所以它可以使数据显示在文本框 - 在扫描显示内部文本字段数据
- 在文本框填充后,显示从数据库的一些数据在
DIV
这是我有:
$(#模式)。点击(函数(){
VAR数据= $(#模式)VAL()。
$(提交输入:text.eq(0))专注()。
VAR海峡=数据;
VAR匹配= str.match(/ [TEJUG2] \ D * D / I);
$阿贾克斯({
类型:后,
网址:process1.php
数据:包装=+匹配+&放大器;行动= packcond
缓存:假的,
异步:假的,
成功:函数(RES){
$('#值)。replaceWith(
< DIV ID ='值'>< H6>中+资源+< / H6>< / DIV>中
);
}
});
});
但我认为这不是解决problem.can,你能帮我吗? : - )
解决方案
$(#模式)。改变(函数(){
$('#系列)专注()。
});
$('#系列')。改变(函数(){
VAR数据= $(#模式)VAL()。
VAR海峡=数据;
VAR匹配= str.match(/ [TEJUG2] \ D * D / I);
$阿贾克斯({
类型:后,
网址:process1.php
数据:包装=+匹配+&放大器;行动= packcond
缓存:假的,
异步:假的,
成功:函数(RES){
$('#值)。replaceWith(
< DIV ID ='值'>< H6>中+资源+< / H6>< / DIV>中
);
}
});
});
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>"
);
}
});
});
but 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>"
);
}
});
});
这篇关于显示使用后.focus在DIV数据()jQuery中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文