Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/80765-solved-html-submit-differences/
Share on other sites

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...

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.