how to read character behind some text

Posted by klox on Stack Overflow See other posts from Stack Overflow or by klox
Published on 2010-06-04T06:39:32Z Indexed on 2010/06/04 6:49 UTC
Read the original article Hit count: 344

Filed under:

this one a code for read two character behind text "KD-R411ED"

var code = data[0].substr(data[0].length - 2);

how to read ED character if text like KD-R411H2EDT? i want a new code can combine with code above..please help!!

look this:

$("#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');
                                                }
                                                 }

© Stack Overflow or respective owner

Related posts about JavaScript