Everything works beautifully except the Room and Board area. The code:
<?php
if (isset($_POST['submit'])) {
$errors=0;
//Room and Board primaries
if ($_POST['housing_plans']!='') {
$housing_plans=$_POST['housing_plans'];
} else {
$errors++;
}
//Room and Board secondaries
if ($_POST['housing_option']!='') {
$housing_option=$_POST['housing_option'];
} else {
$errors++;
}
if ($_POST['meal_option']!='') {
$meal_option=$_POST['meal_option'];
} else {
$errors++;
}
echo "1".$housing_plans." 2".$housing_option." 3".$meal_option."<br />";
//Error check
if ($errors!=0) {
echo "All fields are required. Please fill in all fields and try again.<br />";
} else {
echo "<meta http-equiv='refresh' content='0;url=new_calc_final.php' />";
}
}
?>
<h2>Cost of Attending Calculator</h2>
<h4><em>All fields are required.</em></h4>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
<div>
<h3>Room & Board</h3>
<strong>Housing plans:</strong>
<select onchange="show('targetDIV',this.value)" name="housing_plans">
<option value="">Select one...</option>
<option value="Off-Campus">Off-Campus</option>
<option value="Garrett Hall">On-Campus: Garrett Hall</option>
<option value="Laker Hall">On-Campus: Laker Hall</option>
</select>
<div id="targetDIV" style="display:none;"></div>
<div id="Off-Campus" style="display:none;">
<input type='hidden' name='housing_option' value='None' />
<input type='hidden' name='meal_option' value='None' />
<hr />
<em>Due to extreme variances in off-campus housing costs, these figures will not be calculated.</em>
</div>
<div id="Garrett Hall" style="display:none;">
<input type='hidden' name='housing_option' value='Double room' />
Select meal plan: <select name='meal_option'>
<option value=''>Select one...</option>
<option value='10 meal plan'>10 meal plan</option>
<option value='12 meal plan'>12 meal plan</option>
<option value='16 meal plan'>16 meal plan</option>
</select>
</div>
<div id='Laker Hall' style='display:none;'>
Housing options: <select name='housing_option'>
<option value=''>Select one...</option>
<option value='Single room'>Single room</option>
<option value='Double room'>Double room</option>
</select>
<br />
Select meal plan: <select name='meal_option'>
<option value=''>Select one...</option>
<option value='10 meal plan'>10 meal plan</option>
<option value='12 meal plan'>12 meal plan</option>
<option value='16 meal plan'>16 meal plan</option>
<option value='None'>No meal plan</option>
</select>
</div>
</div>
<div>
<input type='submit' name='submit' value='Submit' />
</div>
<script language="javascript">
function show(target,src) {
var targetContainer = document.getElementById(target);
var sourceContainer = document.getElementById(src);
if(sourceContainer != null && targetContainer != null) {
targetContainer.innerHTML = sourceContainer.innerHTML;
targetContainer.style.display = "block";
}
else {
targetContainer.style.display = "none";
}
//return false;
}
</script>
</form>
The Javascript portion works fine. The items display only when they are supposed to. However, the form fields within the Javascript affected areas are not passing values to the PHP form handling on submit.
I used this exact same piece of Javascript on another page of the form and it works perfectly. I even tried to copy and paste the code from the other page into this one and modify the content to no avail.
I am hoping I am missing something simple and stupid. Any help you can provide will be GREATLY appreciated!!
Thanks, guys!

New Topic/Question
Reply





MultiQuote




|