Trouble with a listbox displaying twice
Posted: Sun Apr 26, 2009 7:14 pm
I am trying to create a page that allows the user to create a schedule of classes. I have created a form that allows the user to do one of two things: 1. They can choose to just enter a unique class number assigned to each individual class(CRN Number) or 2. They can choose a department from a list box, which would then display a list box of the classes offered in that department that can be chosen. However for some reason I can not figure out how to stop it from displaying the department list box twice. It should only create the class list box and display that once the button "Choose" is clicked. However, when I choose a department and click choose it displays 2 department list boxes and the class list box as well. Can someone please help me out? The two list boxes are contained in "deptListBox.inc" and "classListBox.inc". Here is the code:
Code: Select all
<?php
session_start();
//files to connect to database
include("db.inc");
include("error.inc");
include("mydb.inc");
include ("validation_functions.php");
$userName= getenv('REMOTE_USER');
$formValid=true;
//intialize all form variables to defaults
$deptID=0;
$classID=0;
$compNum="";
//reset form variables to value passed in
if(isset($_POST['lstDepts'])) $deptID=$_POST['lstDepts'];
if(isset($_POST['lstClass'])) $classID=$_POST['lstClass'];
if(isset($_POST['txtCRNNumber'])) $compNum=$_POST['txtCRNNumber'];
if(isset($_POST['butChoose']))
{
$session['deptNum'];
$_SESSION['deptNum']=$deptID;
}
else
if(isset($_POST['butSubmit']))
{
//Do insert Here
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>UVM Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="menu.css" />
</head>
<body>
<div id="uvmImage">
<img src="uvm.gif" alt="University of Vermont" height=72px width=174px/>
</div>
<div id="menu">
<ul>
<li><a href="https://www.uvm.edu/~tlia/cs148/final/main/main.php" title="Home">Home</a></li>
<li><a href="https://www.uvm.edu/~tlia/cs148/final/main/capacity.php" title="Class Capacity">Check Class Capacity</a></li>
<li><a href="https://www.uvm.edu/~tlia/cs148/final/main/addClass.php" title="Add Class">Add a Class</a></li>
<li><a href="https://www.uvm.edu/~tlia/cs148/final/main/dropClass.php" title="Drop Class">Drop a Class</a></li>
<li><a href="https://www.uvm.edu/~tlia/cs148/final/main/changeEmail.php" title="Change Email">Change Email</a></li>
<li><a href="https://www.uvm.edu/~tlia/cs148/final/main/dropAll.php" title="Drop All">Drop All Classes</a></li>
</ul>
</div>
<div id="header">
<h1>Add A Class</h1>
</div>
<div id="content">
<form action=""
method="post"
id="frmRegister"
enctype="multipart/form-data"
onsubmit="return fblnVerified(this)">
<fieldset class="wrapper">
<legend>Complete one field to add a class</legend>
<fieldset class="listBox">
<legend>Choose a department & then a class</legend>
<?php include ("deptListBox.inc");
if(isset($_POST['lstDepts']))
include ("classListBox.inc");
?>
<input type="submit" id="butChoose" name="butChoose" value="Choose"
tabindex="1" class="button" />
</fieldset>
<fieldset class="crnNum">
<legend>Or enter</legend>
<label for="txtCRNNumber" class="required">CRN Number</label>
<input type="text" id="txtCRNNumber" name="txtCRNNumber" tabindex="2"
size="20" maxlength="5" onfocus="this.select()" value=''
</fieldset>
<br />
<legend></legend>
<input type="submit" id="butSubmit" name="butSubmit" value="Submit"
tabindex="2" class="button" />
<input type="reset" id="butReset" name="butReset" value="Reset Form"
tabindex="3" class="button" onclick="reSetForm()" />
</fieldset>
</form>
</div>
</body>
</html>