NerdConcepts Posted September 30, 2007 Share Posted September 30, 2007 Some may know that all a barcode scanner does it act like your typing in the number from the bar code really fast, ex: less then a second. What I am trying to pull off is an input text and when it notices a bar code it will run a query pulling that piece of inventory. I know how to process the query and all that, just don't know how to write a script that notices when something is placed in the box and then run the query. I would need to delay for about 1/2 a second before running the query because somethings the barcode scanner isn't all that fast on some slower machines. Is this possible even with PHP or do I need to start looking into Javascript? Thanks. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 30, 2007 Share Posted September 30, 2007 PHP could handle the number but you would need some kind of java-applet or scanning softwasre which ran a macro to submit number to a certain number textbox on a page which is then submitted to your php script so in a way it's not possible to be archeived with PHP. Liam Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 30, 2007 Share Posted September 30, 2007 it all depends on the barcode.. ie an EAN13 is 12 to 13 numbers (last one being the checksum) your probably need some javascript that validates the barcode and then when that matches checks the database, I think your going to need to do some javascript for the ajax style command to call the php code.. Quote Link to comment Share on other sites More sharing options...
NerdConcepts Posted October 1, 2007 Author Share Posted October 1, 2007 I was exacting to have to tap into ajax. Also macro software is not needed. When the cursor is placed inside any text area/ or text element, the scanner will automatically place the scanned bar code into that box. I am going to just attempt to use javascript to do an on change command and it should be able to then check to see if the product exists in the system and run whatever after that. To bad I have no idea how to do much of anything with javascript. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted October 1, 2007 Share Posted October 1, 2007 ahh kewl thats fine then sorry didnt realise it liturally just pasted the code into the box.. Yeah you will need an onchange but it's only classed as a change after you have left the control therefore you will most likley just need to press enter to submit the form. Liam Quote Link to comment Share on other sites More sharing options...
NerdConcepts Posted October 1, 2007 Author Share Posted October 1, 2007 Yeah the whole pressing enter thing seems the only way to do it. I looked into tracking what is in the text field. Example: to submit after 11 characters are in the text field but that doesn't seem possible either. Crap, I was trying to make it as easy as possible. Since later on I'll be tracking which employee has what inventory and it would be really easy to just pre-select an employee and just start scanning in bar codes. Since my scanner is wireless and I wanted the ability to just walk in the storage room and scan them in, lol. Lazy I know but it saves a lot of time in the middle of the night. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 2, 2007 Share Posted October 2, 2007 a few options With a combo of javascript/ajax you could do a onChange for the input to say onchange run an ajax that gets that items inventory and displays it on that page. That is a difficult one, but very nice when done. You will also want to design an onblur focus the text box so that it never loses focus and then your machine can operate with only the scanner. Another option is most barcodes have an option foa delimeter to add after the code is read, just add an enter a tab enter combo so that it submits the form. That is a lot easier, as it don't use ajaxs. Quote Link to comment Share on other sites More sharing options...
NerdConcepts Posted October 2, 2007 Author Share Posted October 2, 2007 Yeah since well I have no idea how to really use ajax, used bits for simple things like if a category in a selection menu is selected it then shows all of it's sub-categories in another select field. But this, this is way over my head when it comes to ajax, since the other stuff was a friend of mines code and i modified it to work right. It also used PHP files to put together the select fields. I may be able to modify the code i have used before to try to get it to run something different, i'll have to look into it and test some. Thanks. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 With a scanner system i wrote awhile ago, the scanner stored the scanned data, i then downloaded this onto my pc as a text file, now i used a Desktop app i wrote with this but surely you could do the same with php just upload it first?? Quote Link to comment Share on other sites More sharing options...
shocker-z Posted October 2, 2007 Share Posted October 2, 2007 Here is what your looking for mate, tis javascript as php cant do this.. <script language="javascript"> <!-- function checkchars(cur) { var maxlength = 9; if (cur.value.length > maxlength) { document.test.submit(); } } </script> <body> <form id="test" name="test" method="post" action=""> <label> <input type="text" name="textfield" id="textfield" onkeyup="checkchars(this)"/> </label> <p> <label> <input type="submit" name="button" id="button" value="Submit" /> </label> </p> </form> Tested and working mate with firefox and IE 6, you proberly would have got a solution faster submitting this on a javascript forum. Liam Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 will work but only with 1 barcode length, if you wanted to extend it your need to add a timer so if its set to 9 chars wait for 2 seconds, if its still at 9 chars then submit else wait 2 seconds, after 6 seconds (assume a problem and clear) this will allow you to use different length barcodes etc.. but it really depends on how complex you want to go Quote Link to comment Share on other sites More sharing options...
shocker-z Posted October 2, 2007 Share Posted October 2, 2007 well it's actualy 10charactors when it submits as 9doesnt and the 10th forces the submit should have done >= 10 then it would have been fine.. Yeah im just giving the basics really i mean he can easily search google for wait timers and then do another check but it could get as you say really complex. I thought in general places has the same length barcard numbers as to what type the scann is set to scan in. Could always add a few fields with difference lengths but then again might as well just press enter if you have to select a text box anyway. Regards Liam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.