.change(function) can control two command
Posted
by klox
on Stack Overflow
See other posts from Stack Overflow
or by klox
Published on 2010-06-04T04:40:15Z
Indexed on
2010/06/04
6:49 UTC
Read the original article
Hit count: 282
JavaScript
|jQuery
dear all..i've a textfield, it using barcode scanner for input data..after scan it shows KD-R411ED 105X0001... I'm successful separate them into two text field use ".change(function)"
$("#tags1").change(function() {
var barcode;
barCode=$("#tags1").val();
var data=barCode.split(" ");
$("#tags1").val(data[0]);
$("#tags2").val(data[1]);
});
what i want is beside make them separate after ".change(function)" another script can read two character behind "KD-R411ED"..that is "ED"..this character can make a radiobutton which id="check1" are checked..
what's code which can combine with code above?
this my complete code..
$("#tags1").change(function() {
var barcode;
barCode=$("#tags1").val();
var data=barCode.split(" ");
$("#tags1").val(data[0]);
$("#tags2").val(data[1]);
var code = data[0].substr(data[0].length - 2); // suggested by Jan Willem B
if (code =='UD') $('#check1').attr('checked','checked');
} else {
if (code == 'ED') {
$('#check2').attr('checked','checked');
}
}
and this the form
<input id="check1" type="radio" class="check" name="check" onclick="addtext()" value="U" />U
<input id="check2" type="radio" class="check" name="check" onclick="addtext_1()" value="E" />E
the radiobutton still not response
© Stack Overflow or respective owner