Solved

Change input focus on a .php form

Posted on 2013-06-13
3
359 Views
Last Modified: 2013-11-26
Good Afternoon

I have a simple web form, which I am populating with a scanner. The code below is from this form.

The problem I have is when this form is viewed and used on my iphone, the input field does not progress to the next input box, however when the form is populated on my PC via the scanner the focus moves onto the next input box?

Thank you

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
   <head >
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
      <title >Form Page: BC_Audit</title>
      <script src='scripts/jquery-1.7.2.min.js' type='text/javascript'></script>
      <script src='scripts/sfm-png-fix.js' type='text/javascript'></script>
      <script src='scripts/sfm_validatorv7.js' type='text/javascript'></script>
      <link rel='stylesheet' type='text/css' href='style/BC_Audit.css?r=%sfm_css_rand%'/>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

 </head>
   <body id='sfm_BC_Audit_body'>
      <form id='BC_Audit' class='sfm_form' method='post' action='%sfm_self_script%' accept-charset='UTF-8'>
         <div id='BC_Audit_errorloc' class='error_strings' style='width:300px;text-align:left'>%sfm_error_display_loc%</div>
         <div id='BC_Audit_outer_div' class='form_outer_div' style='width:300px;height:400px'>
            <div style='position:relative' id='BC_Audit_inner_div'>
               <input type='hidden' name='sfm_form_submitted' value='yes'/>
               <input type='hidden' name='%_sfm_form_id_iput_var_%' value='%_sfm_form_id_iput_value_%'/>
               <div><input type='text' name='t86c5cff731eb00b53f02' id='t86c5cff731eb00b53f02'/></div>
               <div id='Cabinet_Name_container'>
                  <input type='text' name='Cabinet_Name' id='Cabinet_Name' value='%Cabinet_Name%' size='20' class='sfm_textbox'/>
               </div>
               <div id='Cabinet_U_Height_container'>
                  <input type='text' name='Cabinet_U_Height' id='Cabinet_U_Height' value='%Cabinet_U_Height%' size='20' class='sfm_textbox'/>
               </div>
               <div id='Make_container'>
                  <input type='text' name='Make' id='Make' value='%Make%' size='20' class='sfm_textbox'/>
               </div>
               <div id='Model_container'>
                  <input type='text' name='Model' id='Model' value='%Model%' size='20' class='sfm_textbox'/>
               </div>
               <div id='Submit_container'>
                  <input type='image' name='Submit' id='BC_Audit_Submit_img' src='images/BC_Audit-Submit-0.png' alt='submit'/>
               </div>
            </div>
         </div>
      </form>

<script>
$('input').keypress(function(e) {
      if (e.keyCode==13) {
            e.preventDefault()
            $(this).parent().next('div').find('input').focus();
      }
})
</script>

      <script type='text/javascript'>
// <![CDATA[
sfm_fix_png("BC_Audit_Submit_img","images/spacer.gif");

// ]]>
      </script>
      <script type='text/javascript'>
// <![CDATA[
var BC_AuditValidator = new Validator("BC_Audit",{enable_smart_live_validation:false});
BC_AuditValidator.addValidation("Cabinet_Name",{required:true,message:"Please fill in Cabinet_Name"} );
BC_AuditValidator.addValidation("Cabinet_U_Height",{required:true,message:"Please fill in Cabinet_U_Height"} );
BC_AuditValidator.addValidation("Cabinet_U_Height",{numeric:true,message:"The input for Cabinet_U_Height should be a valid numeric value"} );
BC_AuditValidator.addValidation("Make",{required:true,message:"Please fill in Make"} );
BC_AuditValidator.addValidation("Model",{required:true,message:"Please fill in Model"} );

// ]]>
      </script>
   </body>
</html>

Open in new window

0
Comment
Question by:Washcare
  • 2
3 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39244825
Try changing keypress to keydown
0
 

Accepted Solution

by:
Washcare earned 0 total points
ID: 39244883
GaryC123

I take it this change is on line 42? If it is I have just adjusted the code and it makes no difference, the input focus is not the next input field.

Thanks
0
 

Author Closing Comment

by:Washcare
ID: 39677044
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
view results of google SQL query 9 52
iOS 10.1.1 2 46
No Auto-Correction for Local Words on iOS 10.1 5 35
Need script to search multiple files in one drive 13 30
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now