stockton Posted December 8, 2007 Share Posted December 8, 2007 Could someone please explain why the following code works fine in IE when the Enter button is pressed .....snip...... <?php $i = rand(); if ($SGM == 1) { echo "<form name = 'GetData' id='GetData' method='post' action='TI4SGM-3.php?Diva=$i'>"; } ....snip..... <input type=text name="CardNumber" id="CardNumber" onChange='submit_click(this.value)'> .....snip..... <script language=javascript> function submit_click(KaartNommer) { if ((KaartNommer[0] == ";") && (KaartNommer[strlen(KaartNommer) -1] == "?")) { KaartNommer.substr(1,(strlen(KaartNommer) - 2)); } GetData.submit(); } </script> but in another program I have to press tab to get the correct result. ....snip..... <?php $i = rand(); echo "<form name='GetBundle' id='GetBundle' method='post' action='TI6SCAN-4.php?Diva=$i'>"; .....snip..... <input type=text name="BundleNum" id="BundleNum" onChange='submit_click(this.value)'></td> .....snip..... <script language=javascript> function submit_click(KaartNommer) { if ((KaartNommer[0] == ";") && (KaartNommer[strlen(KaartNommer) -1] == "?")) { KaartNommer.substr(1,(strlen(KaartNommer) - 2)); } GetBundle.submit(); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/80765-solved-html-submit-differences/ Share on other sites More sharing options...
ToonMariner Posted December 9, 2007 Share Posted December 9, 2007 you should not rely on keypresses to do anything for you when the focus is not on the submit button... You shoudl not even code javascript to submit a form on pressing enter. WHY? people chose browsers because they like what the do - don't override the default actions of them - don't rely on any particular browser doing what you expect when it comes to forms. Stick with clean markup and don't force anything and you won't get the problems you are trying to solve... the reason you are experiencing this is the onchange even is slightly different in different browsers - some will trigger when you actually change the element some will trigger when you have move the focus away from the element and it has detected that the value has changed... Quote Link to comment https://forums.phpfreaks.com/topic/80765-solved-html-submit-differences/#findComment-410061 Share on other sites More sharing options...
stockton Posted December 9, 2007 Author Share Posted December 9, 2007 Sorry, I probably did not explain this clearly enough. This is not a difference in browsers but a difference in two applications running in IE. There is no other browser involved. I am starting to wonder if I am not making more of these programs than required. What is needed is that the user, using IE only(as this is intranet), completes one field and presses enter. The completion of the field is either by typing, cut and paste or scanning but in all cases Enter is pressed. Now what is the simplist way to achieve this? Quote Link to comment https://forums.phpfreaks.com/topic/80765-solved-html-submit-differences/#findComment-410176 Share on other sites More sharing options...
stockton Posted December 9, 2007 Author Share Posted December 9, 2007 Add the following immediately following the input text field:- <input type="submit" style="width:0px;height:0px;border:none"> Quote Link to comment https://forums.phpfreaks.com/topic/80765-solved-html-submit-differences/#findComment-410242 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.