troubleshooting Question

Allowing Users to Use the Carriage Return to submit a form

Avatar of JJ123
JJ123 asked on
JavaScript
17 Comments1 Solution453 ViewsLast Modified:
I have a form that I need to allow users to scan in data into a field. The barcode that they are scanning has a carriage return at the end. I need to allow that carriage return to submit the form rather than having them hit enter. I tried to use some JavaScript to do this but I am having no luck. Here is my code:

<?php
include 'include/connect.include';
$page="New Orders";

include 'include/header.include';

?>
<SCRIPT LANGUAGE="JavaScript">
<!--

function checkEnter(e)
{ //e is event object passed from function invocation
      var characterCode //literal character code will be stored in this variable

      if(e && e.which)
      { //if which property of event object is supported (NN4)
            e = e
            characterCode = e.which //character code is contained in NN4's which property
      }
      else
      {
            e = event
            characterCode = e.keyCode //character code is contained in IE's keyCode property
      }
      //alert(e);
      if(characterCode == 13)
      { //if generated character code is equal to ascii 13 (if enter key)
            document.forms[0].submit() //submit the form
            return false
      }
      else
      {
            return true
      }

}

-->
</script>

<?php

      if(isset($_GET['error']))
      {
            $error = $_GET['error'];
            print "<font color='red'><b>$error</font></b><br>";
            
      }
if(!isset($_REQUEST['new']) && !isset($_GET['pk']))
{
      ?>
      <!-- <form action='new_orders.php' method='post'> -->
      <table>
      <tr>
      <td>Supervisor:</td><td><input type='text' name='supervisor'></td>
      <td>Picker:</td><td><input type='text' name='picker'></td>
      <td><input type='submit' name='new' class='bn' value='Submit'></td>
      </tr>
      </table>
      </form>
      <?php
}
else
{      
      
      if(isset($_REQUEST['supervisor']))
      {$supervisor = $_REQUEST['supervisor'];}
      if(isset($_GET['sv']))
      {$supervisor=$_REQUEST['sv'];}

      if(isset($_REQUEST['picker']))
      {$picker = $_REQUEST['picker'];}
      if(isset($_GET['pk']))
      {$picker = $_GET['pk'];}

      $query = "SELECT * FROM orders WHERE picker = '$picker' AND qa = '0' AND inv_issue='0'
      AND packed='0' AND xship='0' AND ship_confirm='0' AND xship_issue='0'";
      $result = mysql_query($query) or die(mysql_error());
      $line = mysql_fetch_array($result);
      if(mysql_numrows($result) > 0)
      {
            $supervisor = $line['supervisor'];
            $picker = $line['picker'];
            print "<font color='red'><b>Attention:This picker already has an active pick list.</font></b><br>";
      }
      if(isset($_GET['error']))
      {
            $error = $_GET['error'];
            print "<font color='red'><b>$error</font></b><br>";
            
      }
      if($picker == '' || $supervisor == '')
      {
            print "<font color='red'><b>Supervisor and picker names are required.</font></b><br>";
            exit();
      }
      ?>
      
      <table>
      <tr>
      <td><big>Supervisor:</b></td><td><big><?php echo $supervisor; ?></td></tr>
      <tr><td><big>Picker: </b></td><td><big><?php echo $picker ?></td>
      </tr></table>

      <br><b>Enter a new order to this pick list below:<br></b>
      <form action='results.php' method='post' name='order'>
      <table>
      <tr><td><center><b>Movement Order</b></td><td><b>Hot</b></td>
      </tr>
      <tr>
      <td><input type='text' name='order_num' onKeyPress="checkEnter(event)"> </td>
      <td><input type='checkbox' name='hot'></td>
      
      <input type='hidden' name='supervisor' value='<?php echo $supervisor; ?>'>
      <input type='hidden' name='picker' value='<?php echo $picker; ?>'>
      <input type='hidden' name='list_id' value='<?php echo $line['pick_list_id']; ?>'>
      <td colspan='10'><center><input type='submit' class='bn' value='Save' name='new_pick'></td></tr>
      </table>
      </form>
      <?php

      
      $qpick = "SELECT * FROM orders WHERE picker = '$picker' AND qa = '0' AND inv_issue='0'
      AND packed='0' AND xship='0' AND ship_confirm='0' AND xship_issue='0'";

      $rpick = mysql_query($qpick) or die(mysql_error());
      if(mysql_numrows($rpick) != '0')
      {
            ?>
            <br><b>Below is the current/active pick list for this picker:<br>
            <table>
            <tr><td><center><b>Movement Order</b></td><td><b>Hot</b></td>
            </tr>
            <?php

            for($i=0;$i<mysql_numrows($rpick);$i++)
            {
                  $pick_list = mysql_fetch_array($rpick);
                  ?>
                  <form action='results.php' method='post'>
            
                  <tr>
             <td><input type='text' name='order_num' value='<?php echo $pick_list['order_num']; ?>'></td>
                  <?php
                  if($pick_list['hot'] == '1')
                  {print"<td><input type='checkbox' name='hot' checked='checked'></td>";}
                  else
                  {print"<td><input type='checkbox' name='hot'></td>";}
                  ?>
                  
                  <input type='hidden' name='org_order_num' value='<?php echo $pick_list['order_num'] ?>'>      
                  <input type='hidden' name='list_id' value='<?php echo $pick_list['pick_list_id'] ?>'>      
                  <input type='hidden' name='picker' value='<?php echo $pick_list['picker'] ?>'>
      
                  <td colspan='10'><center><input type='submit' class='bn' value='Edit' name='change'></td></tr>
                  
                  </form>
                  <?php
            }
            print "</table>";

            ?>
      <br>To transfer this pick list to another picker, scan the name below and click transfer.<br>
      <form action='results.php' method='post'>
      <input type='text' name='new_picker'>      
      <input type='hidden' name='list_id' value='<?php echo $pick_list['pick_list_id'] ?>'>      
      <input type='submit' name='transfer' value='Transfer'>
      </form>
      <?php
      }      
}
include 'include/footer.include';

Any help would be appreciated.

Thank you!
ASKER CERTIFIED SOLUTION
b0lsc0tt
IT Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros