• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

need some php help "Enter key" submit in IE

Scarpozzi

Lifer
I'm trying to figure out how to get the enter key to submit a form using php. Does anyone know what I need to do to get this to work? Thanks-

-Scar


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<body ******="javascript😀ocument.sidform.mysid.focus();">
<head>
<link rel="stylesheet" type="text/css" media="screen" href="SIS.css" title="PW Stylesheet"/>
<script type="text/javascript" src="/Resources/JS/win_func.js">//</script>
<title>Security Verify</title>
</head>
<div class="form">
<label for="sidform">Please verify your SID to protect your information</label>
<form method="POST" action="menu.php?pageid=sidpage&amp;form=sidform&amp;tid=pu3OfMCofgcAAAS6LScAAA
L" class="twocol" id="sidform" name="sidform">
<table>
<tr>
<td align="right">
<label for="mysid">Secure ID</label>
</td>
<td>
<input type="password" name="mysid" size="9" maxlength="9" value="" id="mysid"/>
</td>
</tr>
<tr>
<td>
<input type="submit" name="action" value="Verify SID"/>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
 
Sorry if this is noise. In .Net 2.0, the Form allows a default button declaration (not in 1.1). Query to see if the version you are using allows that and then you can set the submit button to the default action and Enter then will then hit the button. Otherwise, I am just wasting your time and apologize in advance.
 
Originally posted by: gsellis
Sorry if this is noise. In .Net 2.0, the Form allows a default button declaration (not in 1.1). Query to see if the version you are using allows that and then you can set the submit button to the default action and Enter then will then hit the button. Otherwise, I am just wasting your time and apologize in advance.
No need to apologize. I doubt this is being compiled in .net. I've got the end source from the page, but know little about what else is going on in the directory structure. I'm more of an end-user with this php page than the programmer....just trying to help them out since it's not working for them. Whatever it is they've tried didn't work and had to roll out the page. My php guides aren't helping me, thus I post to the smart programmers of AT. 😀
 
i copied the code and made a page on my server
it DOES submit when hitting enter

from what i understand, the enter button will submit the form in IE only if there's a single text input

if there's more than one, the enter button won't submit
 
Well, here's what happens...

I enter in the code it's asking for and press enter. The field clears and it gives me an error message that the code was not submitted. However, if I click on the button, it submits. I'm not sure what it would take for enter to take on the action of the button. I'm sure there's a javascript way to fix this.

It appears that clicking the button is doing something extra that pressing enter does not...I'm not sure what or where... I'm looking into it, but still, any suggestions are appreciated. Thanks gsellis and troytime...
 
ok, i changed the action of your form and tested it
the mysid input passes whether i hit enter OR click the button

show me the code thats trapping that data (where it outputs the error about the code not being submitted)

i successfully echoed it from the post array both ways ($_POST['mysid'])

the other variables in the form action will be in the _GET array
 
I've had this problem before.

I had code like this:

if (isset($_POST['variable_name'])) {
// form submitted
}

I read that there was a problem in IE that didn't detect Enter key presses with code like that. So I added a hidden element to the form:
<input type="hidden" name="_submit" value="1" />

Then the PHP code to check if it was submitted:
if (array_key_exists('_submit', $_POST)) {
// submitted
}
 
Back
Top