SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help in input data from barcode to textbox then move cursor to next textbox

    Hi..

    I need to input data in my textbox by scanning barcode then the data will input to textbox then the cursor focus move to next textbox until it goes to last textbox then save data.

    How is it possible?

    I'm not familiar with ajax

    I am right that ajax/jquery code will do it?

    here is my sample code:

    Code:
    <?php
        error_reporting(0);
       date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    mysql_select_db("mes", $con);
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    <html> 
    <head> 
    <script type="text/javascript" > 
     
    // this variable says how many characters you allow 
    // to input in each textbox 
    var input_size = 3; 
     
    function checkTextBox( ct ) 
    { 
        var tab = ct.tabIndex; 
                     
             if ( ct.value.length == input_size ) 
            { 
                for(i=0; i<document.barcode.elements.length; i++) 
                { 
                          if( document.barcode.elements[i].tabIndex == (tab+1) ) 
                         {    
                             document.barcode.elements[i].focus(); 
                             break; 
                         } 
              } 
        }         
    }; 
     
    </script> 
     
    </head> 
    <body onLoad="document.barcode.code_read_box1.focus();"> 
    <form name="barcode" > 
    <input type="text" tabindex="1" id="code_read_box1" value="" onKeyPress="checkTextBox(this);"/><br/> 
    <input type="text" tabindex="2" id="code_read_box2" value="" onKeyPress="checkTextBox(this);"/><br/> 
    <input type="text" tabindex="3" id="code_read_box3" value="" onKeyPress="checkTextBox(this);"/><br/> 
    <input type="text" tabindex="4" id="code_read_box4" value="" onKeyPress="checkTextBox(this);"/><br/> 
    <input type="text" tabindex="5" id="code_read_box5" value="" onKeyPress="checkTextBox(this);"/><br/> 
    <input type="text" tabindex="6" id="code_read_box6" value="" onKeyPress="checkTextBox(this);"/><br/> 
    </form> 
    </body> 
     
    </html>
    In that code I use javascript, but the problem in my code is it move to another textbox after i input 3 characters but it did not what I want because i need to use barcode instead of keyboard.

    I hope somebody can help me.

    Thank you so much

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,713
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    In that code I use javascript, but the problem in my code is it move to another textbox after i input 3 characters
    That would be due to the code that says:
    var input_size = 3;

    Quote Originally Posted by newphpcoder View Post
    but it did not what I want because i need to use barcode instead of keyboard.
    I don't think that Javascript can be of any assistance when it comes to using barcodes.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    That would be due to the code that says:
    var input_size = 3;



    I don't think that Javascript can be of any assistance when it comes to using barcodes.
    Thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •