Thanks, I got it working. ONe other question, my form works if I press the submit button, but If I just hit the enter key, it doesn't do my validation subroutine, it just loads the page again. Any suggestions? my page code is below:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Documentation Repository</title>
<link rel="stylesheet" href="nav/vorfa_style.css" type="text/css">
<? include "nav/head.php" ?>
</head>
<body bgcolor="#ffffff" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" bottommargin="0" rightmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">
<? include "nav/top.php"; ?>
</td>
</tr>
<tr>
<td width="3%" rowspan="9" valign="top" bgcolor="#9cb0d3">
<script>initializeDocument()</script>
</td>
<td valign="top">
<?
if ($submit) {
if (validate_form()) {
display_show();
} else {
display_form();
}
} else {
display_form();
}
?>
<? function display_form() {
global $cust_nbr, $err_cust_nbr, $err_cnt;
?>
<form method="post" action="get_custnbr.php">
<table width="53%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="47%" valign="top">Customer Number:</td>
<td width="53%"><input name="cust_nbr" type="text" id="cust_nbr" size="9" maxlength="9" value="<? echo $cust_nbr ?>">
<? if (strlen($err_cust_nbr)) {
echo "<br><small><font color=red>$err_cust_nbr</font></small>";
} ?>
</td>
</tr>
<tr>
<td colspan="2" valign="top"><p align="center">
<input type="submit" name="submit" value="Get Customer Number">
</p></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"><strong></strong></td>
</tr>
<tr>
<td valign="top"><p> </p></td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
</html>
<? }?>
<? function display_show() {
global $cust_nbr, $cust_nbr_new, $err_cust_nbr, $err_cnt;
?>
<table width="44%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="47%" valign="top">Customer Number:</td>
<td width="56%">
<?
$cust_nbr_new = $cust_nbr -(floor ($cust_nbr/24) *24) +1;
echo "cust" . str_pad($cust_nbr_new,2,"0",STR_PAD_LEFT) ?>
</td>
</tr>
<form name="getcustnbr" method="post" action="get_custnbr.php">
<tr>
<td width="47%">Get Another Customer Number:</td>
<td width="56%"><input name="cust_nbr" type="text" id="cust_nbr" size="9" maxlength="9" value="<? echo $cust_nbr ?>">
<? if (strlen($err_cust_nbr)) {
echo "<br><small><font color=red>$err_cust_nbr</font></small>";
} ?>
</td>
</tr>
<tr>
<td colspan="2" valign="top"><p align="center">
<input type="submit" name="submit" value="Get Customer Number">
</p></td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"><strong></strong></td>
</tr>
<tr>
<td valign="top"><p> </p></td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
</html>
<? } ?>
<?
function validate_form() {
global $cust_nbr, $err_cust_nbr, $err_cnt;
$err_cnt = 0;
if (!strlen(trim($cust_nbr))) {
$err_cust_nbr="Please enter a Customer Number.";
$err_cnt++;
} else if (!is_numeric(trim($cust_nbr))) {
$err_cust_nbr="The customer number must be all numeric.";
$err_cnt++;
}
if ($err_cnt > 0) {
return false;
} else {
return true;
}
}
?>