form submission - IE
Moderator: General Moderators
form submission - IE
i have a php form that searches our database. the formatting is done via css. i've tested the form using Firefox and everything works perfectly. when i tried the form in IE it doesn't work as planned, and i've never seen this before. when entering the search string into the search text box and the user hits enter on the keyboard, nothing happens. the user has to use the mouse to click the search button...again, this only happens in IE.
i don't know if my problem lies in some of my javascript, php, css or something else entirely. does anyone have any idea why hitting Enter does not work unless you click it with the mouse?
i don't know if my problem lies in some of my javascript, php, css or something else entirely. does anyone have any idea why hitting Enter does not work unless you click it with the mouse?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Your script is looking for the submit button to determine if the page has been submitted to. IE does not send the submit button if you hit enter while inside a text box (and a few other controls.) This is why I always, always, always recommend people look for other fields or better yet, $_SERVER['REQUEST_METHOD'] for a post.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Online Course Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" type="text/javascript" src="popup.js">
</script>
<script language="JavaScript" type="text/javascript">
function doClear(theText) {
if (theText.value == theText.defaultValue) {
theText.value = ""
}
}
function doCheck(theText) {
var s = theText.value;
while (s.substring(0,1) ==' ') {
s=s.substring(1,s.length);
}
if (s == "") {
theText.value = "Enter Last Name";
}
}
</script>
<style type="text/css">
<!--
@import url(classes.css);
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<table width="650" border="1" cellspacing="0" cellpadding="3">
<tr>
<td valign="top">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="5"><b>Online
Course Search</b></font><br />
<br />
</p>
<table width="75%" border="0" align="center" cellpadding="3" cellspacing="0" class="header">
<tr>
<td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><b><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">The
quick brown fox jumps over the lazy dog. The quick brown
fox jumps over the lazy dog. The quick brown fox jumps
over the lazy dog. The quick brown fox jumps over the
lazy dog. The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. The quick brown fox
jumps over the lazy dog</font></b></td>
</tr>
<tr>
<td valign="top"> <hr /> </td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div class="search">
<form name="find" id="find" method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
<p>Search For: <strong><?
if($_POST['Submit'] == True){
echo $_POST['lname'];
}
?></strong>
</p>
<p>Last Name:
<input name="lname" type="text" id="lname" value="Enter Last Name" onfocus="doClear(this)" onblur="doCheck(this)" class="searchtext" />
<input name="Submit" type="Submit" id="Submit" value="Submit" class="FormButton" />
</p>
</form>
<?
if($_POST['Submit'] == True){
$db_conn = @mssql_connect("","","") or die( "ERROR: Connection to database failed, please contact the webmaster at <a href=\"mailto:email\">email</a>." );
// select database
mssql_select_db( "DB", $db_conn ) or die( "ERROR: Selecting database failed,<br>Please contact the webmaster at <a href=\"mailto:email\">email</a>." );
$lname = $HTTP_POST_VARS["lname"];
//You should now this but be sure to connect to your database or this is useless. :/
if ($lname == "")
{$lname = '%';}
$result = mssql_query ("SELECT dbo.tbl_class_participant.participant_fname, dbo.tbl_class_participant.participant_lname, dbo.tbl_class_participant.dept_other, dbo.tbl_list_department.department_desc, dbo.tbl_class.class_type_id FROM dbo.tbl_class_participant INNER JOIN dbo.tbl_class_listing ON dbo.tbl_class_participant.participant_id = dbo.tbl_class_listing.participant_id INNER JOIN dbo.tbl_class ON dbo.tbl_class_listing.class_id = dbo.tbl_class.class_id INNER JOIN dbo.tbl_list_department ON dbo.tbl_class_participant.department_id = dbo.tbl_list_department.department_id WHERE (dbo.tbl_class_participant.participant_lname LIKE '$lname%') ORDER BY dbo.tbl_class_participant.participant_lname, dbo.tbl_class_participant.participant_fname");
if ($row = mssql_fetch_array($result)) {
do {
echo "<table width = \"625\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"#E0E0E0\"><td width=\"150\"><strong>Name</strong></td><td width=\"200\"><strong>Department</strong></td><td width=\"150\"><strong>Other</strong></td><td width=\"125\"><strong>Class</strong></td></tr>";
echo "<tr><td>";
echo $row["participant_fname"];
echo " ";
echo $row["participant_lname"];
echo "</td><td>";
echo ucwords(strtolower($row["department_desc"]));
echo "</td><td>";
echo $row["dept_other"];
echo "</td><td>";
echo $row["class_type_id"];
echo "</td></tr></table><br />";
} while($row = mssql_fetch_array($result));
} else {print "Sorry, no records were found!";}
}
?>
</div></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Change
to
Code: Select all
<input name="Submit" type="Submit" id="Submit" value="Submit" class="FormButton" />Code: Select all
<input name="anything not equal to submit" type="Submit" id="anything not equal to submit" value="anything not equal to submit" class="FormButton" />- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I'd recommend adding a hidden <input> to the form and checking for it rather than the submit <input>. I just demonstrated a login form that does this here.
(#10850)