Roble Posted August 17, 2006 Share Posted August 17, 2006 Hello,I'm working on my dad's insurance website, and I was making the quotes form. He's told me that he wants the licence number to be entered into 3 text fields, each having a maxlength of 5. But he wants the fields so that when the first text field is filled out, it will go on to the second, and then on to the third after that. He wants it to be automatic, so his potential clients dont have to hit tab. I've tried doing this with JS, but to no avail. Wondering if this can be done using PHP? If not can you give me a better JS script then the one I found? Much appreciated. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 17, 2006 Share Posted August 17, 2006 u could create a script so when text is entered then check if 5 numbers or watever has been entered then focusing on the next box right ? i dont exactly know but u can google it im sure Quote Link to comment Share on other sites More sharing options...
Jeremysr Posted August 17, 2006 Share Posted August 17, 2006 No I'm pretty sure this can't be done in PHP. I think you need to use Javascript, but I'm not sure how to do this. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 17, 2006 Share Posted August 17, 2006 well this time i found it for u create a function on top of page and it would be like [code]<FORM NAME="cc"><INPUT TYPE="text" name="num1" size="5" onKeyUp="check()"><BR><INPUT TYPE="text" name="num2" size="5" onKeyUp="check2()"><BR><INPUT TYPE="text" name="num3" size="5" onKeyUp="check3()"><BR><INPUT TYPE="submit" VALUE="Click to Send" NAME="go"></FORM><?phpfunction check(){var letters = document.cc.num1.value.length +1;if (letters <= 5){document.cc.num1.focus()}else{document.cc.num2.focus()}}function check2(){var letters = document.cc.num2.value.length +1;if (letters <= 5){document.cc.num2.focus()}else{document.cc.num3.focus()}}function check3(){var letters = document.cc.num3.value.length +1;if (letters <= 5){document.cc.num3.focus()}else{document.cc.go.focus()}}?>[/code]sorry jeremy i proved u wrong (i hate doing that) Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 You really dont want to do this in php, Javascript is made for this. There is an entire forum on thsi board dedicated to client side issues... best you ask your question there. Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 Um... BillyBoB's code should be in...[code]<script language="javascript">// code here</script>tags, and included into your <head> seeing as its Javascript and NOT php.[/code] Quote Link to comment Share on other sites More sharing options...
Roble Posted August 17, 2006 Author Share Posted August 17, 2006 Billy your script worked marvelousely (I put it within JS tags like thorpe says to do) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.