I have just modified an old code and now nothing is working. Can you please guide me where I am wrong?
Some things that are not working:
Before that, the focus will always be on the only input field on the screen. (Now it is not), also if the other conditions in the code are not working. The funnel function is not working either.
& lt; Script language = "javascript" & gt; $ (Document) .ready (function () {$ ("# serialNumber"). ध्यान (); $ ("# scroll-pane"). JScrollPane (); $ (document) .keydown (function () {$ ( "#serialNumber") focus ();}); var code = $ ("# hidden serialcode"). Val (); $ ("# serial number"). Key (function () {var $ this = $ ( This); var d = $ (this) .val (); var d5 = d.svstring (0, 5); if (d.length! = 20) {warning ('false serial code');} and if ( D. Length == 20 & amp; d5! = Code) {var serialCode = d.svstring (0, 8); Warning ('Serial code:' + Serial code); $ (this) .val (""); } And if (d.length == 20 & amp; amp; d5 == code) {var flagNumber = d.svstring (0, 6); var error number = d.substring (7, 10); warning ('flag Number '+ v Weight number + '\ N error number' + error number); $ (this) .val ("");}});}); & Lt; / Script & gt;
HTML code: --------------
& lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "text" id = "serialNumber" class = "" / & gt; & Lt; Input type = "hidden" id = "hidden white code" value = "01327" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Div id = "scroll-panel" square = "scroll-panel" & gt;
Old job code: ------
$ (document) .ready (function () {$ ("# serialCode") focus (); $ (Document). Keydown (function () {$ ("#corial code"). Focus ();}); $ ("#corial code") key (function () {var $ this = $ (This); var d = $ (this) .val (); if (d.langha = 5) {//$this.attr("disabled""disabled ") var $ code = d.sfstring ( 0, 8); Alert ('code is' + $ code);}}};});
The main problem in your code is that the $ (" # scroll-panel "). JScrollPane ();
refers to an undefined method.
You remove that code from your code functions.
Then, you have to make sure to use # scroll-panel
:
$ ('html, body'). Chetan ({scrollTop: $ ('# scroll-pane') offset (). Top} , 'Slow');
Additionally, your if
statement should probably be if (d.length & gt; 20)
otherwise you get an error on every single single button. You can do a check with if (d.length! = 20)
.
In addition, you can check a valid serial number before d.length
20 because it shows that the serial number has only 9 lengths.
Finally, in the form of a note, you $ this
as $ (this)
, but then you $ (this )
for values you simply just this.value
.
$ (document) .ready (function () {$ ("# serialNumber"). Focus (); // $ ("# scroll-pane"). JScrollPane (); - Include the plugin if you want to use this. $ (Document) .keydown (function () {$ ("# serialNumber"). Focus ();}); Var code = $ (" $ ("# SerialNumber") keyboard (function () {var $ this = $ (this); var d = $ this.val (); var d5 = d.svstring (0, 5); if (d.length & gt; 20) {Warning ('wrong serial code');} // should it actually be 20 and not 9? And if (D. lamps == 20 & d5 ! = Code) {var serialCode = d.sstring (0, 8); Alert ('Serial code:' + S Radiocode); $ this.val ("");} // what about here? And if (D. lamps == 20 & amp; D5 == code) {var flagNumber = d.svstring (0 , 6); var Error number = D.substring (7, 10); Warning ('flag number' + flag number + '\ nerror number' + error number); $ This.val ("");}}) ;});
Comments
Post a Comment