What I have is just a basic form, but in IE, pressing enter when in a field seems to refresh the page. This php that I use goes through a few different forms (questions) after each submit. Some of them will work if enter is pressed, others will not.
Only happens in IE.
action of the form is PHP_SELF
Thanks for any advice.
[Solved] submitting form to self in IE with one text field
Moderator: General Moderators
[Solved] submitting form to self in IE with one text field
Last edited by Hibba on Thu Dec 23, 2004 4:50 pm, edited 2 times in total.
I think that's just how IE handles form input. If you press enter on a form it will submit to the page that the form action is pointing to... in this case PHP_SELF.
You might be able to trap the ENTER key using javascript sort of like (you'll need to modify it a bit (I'm feeling lazy):
Meaning that if the user presses ENTER in IE; run some code that does... nothing... hopefully solving your problem.
Of course; I like pressing enter to submit a form.
You might be able to trap the ENTER key using javascript sort of like (you'll need to modify it a bit (I'm feeling lazy):
Code: Select all
<body onkeydown="if(event.keyCode == 13){**DO NOTHING?;}">Of course; I like pressing enter to submit a form.
Here is a simple example that does not work correctly in IE.
So basically, I want it to where you hit enter and it will submit, but in IE it does not do this, it refreshes the page.
Code: Select all
<?php
$UserName = file_get_contents('include.html');
if(isset($_POST['submit'])) {
extract($_POST);
if(!empty($name)) {
echo $name;
}
} else {
$form = "<form name ="myform" method="post" action="". $PHP_SELF."">";
$form .= $UserName;
$form .= "<input type="submit" value="Submit" name="submit">";
$form .= "</form>";
echo $form;
}
?>So basically, I want it to where you hit enter and it will submit, but in IE it does not do this, it refreshes the page.
Here is the solution to an interesting problem. In Internet Explorer, if you have a form with one text field and it POSTS to itself, IE will not correctly perform that action. If there are more than one field, there is no problem. The trick is to pass a hidden variable and use that rather than using sumbit as an if(isset(sumbit) or some kind of validation like that.
Here is the URL for a better explanation <http://www.sitepoint.com/forums/showthread.php?t=46675>
Might I say that this is not a problem in other browsers, like Firefox or Safari.
Here is the URL for a better explanation <http://www.sitepoint.com/forums/showthread.php?t=46675>
Might I say that this is not a problem in other browsers, like Firefox or Safari.