newphpcoder Posted May 2, 2012 Share Posted May 2, 2012 Hi..I have form and i want to input data using barcode and it will display on textbox and after input on the first textbox the focus will go to next textbox untill it will go on the last textbox and on the last textbox it will automatically save the data's on the database.How is it possible?here is my sample 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);?><html><head><script type="text/javascript">function ini(){// Retrieve the codevar code =document.getElementById ("code_read_box1").value;var code =document.getElementById ("code_read_box2").value;var code =document.getElementById ("code_read_box3").value;var code =document.getElementById ("code_read_box4").value;var code =document.getElementById ("code_read_box5").value;var code =document.getElementById ("code_read_box6").value;// Return false to prevent the form to submitreturn false;}</script></head><body onLoad="document.barcode.code_read_box1.focus()"><form name=barcode onsubmit = "return ini()"><input type="text" id="code_read_box1" value="" /><br/><input type="text" id="code_read_box2" value="" /><br/><input type="text" id="code_read_box3" value="" /><br/><input type="text" id="code_read_box4" value="" /><br/><input type="text" id="code_read_box5" value="" /><br/><input type="text" id="code_read_box6" value="" /><br/></form></body></html> Link to comment Share on other sites More sharing options...
eTianbun Posted May 2, 2012 Share Posted May 2, 2012 (edited) Try this: When user input data in the textbox and press ENTER key, then it moves focus to the next textboxEXAMPLE: function gotoNEXT(el , ev){evenObj=window.event || evif(eventObj.keyCode==13){el.nextSibling.focus()}} Add this to all textbox, except the last one: onkeypress="gotoNEXT(this,event)" If you know the amount of numbers, that will be entered into the textbox, then there is another way of doing this without the ENTER key and the next textbox gets focus automatically Edited May 2, 2012 by eTianbun Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now