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)

    input data to the textbox after read the barcode using barcode scanner

    Hi..


    I just want to know how does it happen that when I scan the barcode using barcode scanner it will automatically put on the first textbox, then the focus will go to the next textbox and on the last textbox will automatically save the data to database.

    here is my sample form.

    PHP 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);
    $sr_date =date('Y-m-d H:i:s');

    $sql "SELECT sr_number FROM receiving_materials ORDER BY sr_date DESC LIMIT 1";
            
    $result mysql_query($sql$con);
            
            if (!
    $result) {
                echo 
    'failed'
                die();
            }
            
    $total mysql_num_rows($result);
            if (
    $total <= 0) {
                
    $currentSRNum 1;
                 
    $currentYear  = (int)(date('y'));
                
    $currentMonth = (int)(date('m'));
                
    $currentDay = (int)(date('d'));
               
                
    $currentSRYMD substr($row['sr_number'], 06);
                
    $currentYMD date("ymd");
                if (
    $currentYMD $currentSRYMD
                {  
                    
    $currentSRNum 1;
                } 
                else 
                {  
                    
    $currentSRNum += 1;
                }     
                 
            } 
            else {
    //------------------------------------------------------------------------------------------------------------------
                // Stock Number iteration.... 
                
    $row mysql_fetch_assoc($result);
                
                
    $currentSRNum = (int)(substr($row['sr_number'],0,3));
                
                
    $currentSRYear  = (int)(substr($row['sr_number'],2,2));
                
    $currentSRMonth = (int)(substr($row['sr_number'],0,2));
                
    $currentSRNum = (int)(substr($row['sr_number'],6,4));

                
    $currentYear  = (int)(date('y'));
                
    $currentMonth = (int)(date('m'));
                
    $currentDay = (int)(date('d'));
               
                
    $currentSRYMD substr($row['sr_number'], 06);
                
    $currentYMD date("ymd");
                if (
    $currentYMD $currentSRYMD
                {  
                    
    $currentSRNum 1;
                } 
                else 
                {  
                    
    $currentSRNum += 1;
                }                                           
            }
    //------------------------------------------------------------------------------------------------------------------         
            
    $yearMonth date('ymd');    
            
    $currentSR $currentYMD sprintf("%04d"$currentSRNum);  
    ?>
    <html>
    <title>Receiving Materials</title>
    <head>
    <link rel="stylesheet" type="text/css" href="kanban.css" />
    <style type="text/css">
    #SR_date{
        position: relative;
        font-family: Arial, Helvetica, sans-serif;
        font-size: .9em;
        margin-left: 10px;
        width: auto;
        height: auto;
        float: left;
        top : 10px;
        
    }
    </style>


    </head>
    <body>
    <form name="receiving_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">      

    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="sr_date" value="<?php echo $sr_date?>" size="16" readonly="readonly" style="border: none;">    
    </div>
    <div id="SR_number">
    <label>RM# :</label>
    <input type="text" name="sr_number" value="<?php echo $currentSR?>" size="9" readonly="readonly" style="font-weight: bold; border: none;"> 
    </div> 
    <div id="SI_number">
     <label class="LLabelRM">SI/DR# :</label>
    <input type="text" name="si_num" id="si_num" class="LFieldRM" value="" size="25"> <br/></br/>
    <label class="LLabelRM">Supplier Name :</label>
    <input type="text" name="s_name" id="s_name" class="LFieldRM" value="" size="25">  <br/></br/>
    <label class="LLabelSecRM">PO # :</label>
    <input type="text" name="po_num" id="po_num" class="LFieldSecRM" value="" size="25">
    <label class="LLabelSecRM">Quantity :</label>
    <input type="text" name="qty" id="qty" class="LFieldSec1RM" value="" size="25"> <br/> <br/>
    <label class="LLabelSecRM">Material Code :</label>
    <input type="text" name="mat_code" id="mat_code" class="LFieldSecRM" value="" size="25">
    <label class="LLabelSecRM">Material Desc. :</label>
    <input type="text" name="mat_desc" id="mat_desc" class="LFieldSec1RM" value="" size="25">  <br/></br/>
    <label class="LLabelSecRM">WH Code :</label>
    <input type="text" name="wh_code" id="wh_code" class="LFieldSecRM" value="" size="25">
    <label class="LLabelSecRM">BIN Location :</label>
    <input type="text" name="bin_loc" id="bin_loc" class="LFieldSec1RM" value="" size="25">
    </div> 
    </form>
    </body>
    </html>
    Thank you

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    I just want to know how does it happen that when I scan the barcode using barcode scanner it will automatically put on the first textbox
    I don't think that javascript can receive information from a barcode scanner.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    A barcode scanner transmits data it reads as text. All you need to read data from a barcode scanner is a text editor, like notepad. You can do a simple test: open notepad and simply scan a barcode. Also, they can transmit special control codes, like a line feed or carriage return, which can trigger events to help process the scanned result.

    In this case, I suspect javascript takes care of data read from the barcode scanner: it listens to read data event for a text box and then, much like with an AJAX result, it populates the form and submits it.


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
  •