Here's the HTML/PHP file, and below this is the javascript file.
My trigger2 isn't firing.
Code:
<html>
<head>
<script src='js/test.js' type='text/javascript'></script>
</head><body>
<?php
include_once "configHPP.php";
echo '<h2>How Much Education Have You Acquired, GENIUS?</h2>';
echo '<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" method="post">';
if (!isset($_POST['go'])) {
echo "<select id='education' name='education'>";
echo "<option value='Jr.High'>Jr.High</option>";
echo "<option value='HighSchool'>HighSchool</option>";
echo "<option value='College'>College</option></select>";
} else {
if (isset($_POST['education'])) {
if ($_POST['education'] == "College") {
echo "<label>College name: </label><input id='org' type='text' size='30' /><br />";
echo "<label>Zip code: </label><input type='text' size='10' /><br />";
} else {
exit("Not bright - are you?");
}
}
}
?>
<input id="submitbutton" name="go" type="submit" value=" Submit " />
</form></body></html>
javascript file:
Code:
function shout(msg) {
alert(msg);
}
function setTrigger1() {
var picklist = document.getElementById("education");
picklist.onchange = function() {
if (picklist.value != "") {
shout("OPTION changed");
}
}
}
function setTrigger2() {
var org = document.getElementById("org");
org.onchange = function() {
shout("College Name CHANGED");
}
}
window.onload = function() {
setTrigger1();
setTrigger2();
}
Thanks for your help!
|