Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Change input focus on a .php form

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Ever wanted to watch videos in your computer from the bed without the need of standing up and shutting down the computer?  Is your computers operating system Windows XP, Windows Vista or Windows 7?  Do you own a iOS device? If all the answers were y…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

792 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