我不确定添加按钮是否是造成问题的原因,因为它可以在其他浏览器上完美运行。我希望你能以某种方式帮助我。谢谢你。顺便说一下,这是完整的 .php 代码。
<html>
<head>
<LINK REL=StyleSheet HREF="addOfficerStyle.css" TYPE="text/css" MEDIA=screen>
<script type="text/javascript">
function validateForm(action)
{
var lname=document.forms["validation"] ["lname"].value;
var fname=document.forms["validation"] ["fname"].value;
var mname=document.forms["validation"] ["mname"].value;
var address=document.forms["validation"] ["address"].value;
var contact=document.forms["validation"] ["contact"].value;
if (lname==null || lname=="" || fname==null || fname=="" || mname==null || mname=="" || address==null || address=="" || contact==null || contact=="")
{
alert("Fill all required fields");
return false;
}
else{
form = document.getElementById('userLocation');
form.action = action;
form.submit();
}
}
function numeric(e)
{
var unicode=e.charCode ? e.charCode : e.keyCode;
if (unicode==8 || unicode==9 || (unicode >=48 && unicode <=57))
{
return true;
}
else
{
return false;
}
}
function inputLimiter(e,allow)
{
var AllowableCharacters = '';
if (allow == 'Letters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';}
var k = document.all?parseInt(e.keyCode): parseInt(e.which);
if (k!=13 && k!=8 && k!=0)
{
if ((e.ctrlKey==false) && (e.altKey==false))
{
return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1);
}
else
{
return true;
}
}
else
{
return true;
}
}
</script>
</head>
<body onunload="opener.location=('PromoOfficer.php')">
<br><br>
<form id="userLocation" name="validation" method="post" onsubmit="return validateForm()">
<div id="tableAlign">
<table>
<tr>
<td><b>ADD: Promo Officer</td></b>
</tr>
<tr>
<td>Last name:</td> <td><input type="text" name="lname" maxlength="20" onkeypress="return inputLimiter(event,'Letters')" /></td>
</tr>
<tr>
<td>First name:</td> <td><input type="text" name="fname" maxlength="20" onkeypress="return inputLimiter(event,'Letters')" /></td>
</tr>
<tr>
<td>Middle name:</td> <td><input type="text" name="mname" maxlength="20" onkeypress="return inputLimiter(event,'Letters')" /></td>
</tr>
<tr>
<td>Address:</td> <td><input type="text" name="address" maxlength="50" /></td>
</tr>
<tr>
<td>Contact:</td> <td><input type="text" name="contact" maxlength="11" onkeypress="return numeric(event);" /></td>
</tr>
<tr>
<td>User Type:</td> <td><input type name = "usertype" readonly = "true" value = "Promo Officer"></td>
</tr>
</table>
</div>
<div id="addBtn">
<a href="#" onclick="javascript: validateForm(action);return false;"><img src="images/add.png" height="27" width="60"></a>
</div>
<!-- PHP -->
<?
include('global.php');
if(isset($_REQUEST['salesID']))
$pID = $_REQUEST['salesID'];
else
$pID = "";
if(isset($_REQUEST['lname']))
$lname = $_REQUEST['lname'];
else
$lname = "";
if(isset($_REQUEST['fname']))
$fname = $_REQUEST['fname'];
if(isset($_REQUEST['mname']))
$mname = $_REQUEST['mname'];
if(isset($_REQUEST['address']))
$address = $_REQUEST['address'];
if(isset($_REQUEST['contact']))
$contact = $_REQUEST['contact'];
if(isset($_REQUEST['usertype']))
$usertype = $_REQUEST['usertype'];
if($_POST)
{
$query = "INSERT INTO promoofficerform SET ";
$query = $query."LastName='".$lname."', ";
$query = $query."FirstName='".$fname."', ";
$query = $query."MiddleName='".$mname."', ";
$query = $query."Address='".$address."', ";
$query = $query."Contact='".$contact."', ";
$query = $query."UserType='".$usertype."' ";
//$query = $query."WHERE PromoNameID='".$pID."'";
//echo $query;
ExecuteQuery($query);
echo "<script type=\"text/javascript\">
<!--
window.close();
//-->
</script>";
}
?>
<!-- EndOfPHP -->
</form>
</body>
</html>