Solved

Change input focus on a .php form

Posted on 2013-06-13
3
357 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The release of the iPhone 6 and the iPhone 6 Plus was extremely successful for Apple. However when iOS 8.1 was introduced, many iPhone users complained of quick battery drainage. Without even knowing, you may be unnecessarily using up your battery p…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 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

18 Experts available now in Live!

Get 1:1 Help Now