so i am trying to output course information when the course number is selected and the button is clicked.
here is the html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Course Info</title>
</head>
<body>
<h1>Course Information Search</h1>
<form action="" method="post">
<select name="course" id="course">
<option value="420-121">420-121</option>
<option value="420-122">420-122</option>
<option value="420-123">420-123</option>
<option value="420-221">420-221</option>
<option value="420-222">420-222</option>
<option value="420-223">420-223</option>
<option value="420-224">420-224</option>
<select>
Select a course to see the course name and teacher assigned<br><br>
<input type="button" id="go" value="go!">
</form>
<br><br>
<div id="courseInfo"></div>
</body>
</html>
php
<?php
$filename = "data.txt";
try {
if ($courses = @fopen($filename, "r")) {
while (!feof($courses)) {
$line = fgets($courses);
$array = explode(", ", $line);
if (trim($array[0]) == $_GET["course"])
echo $array[1] . ", " . $array[2];
}
fclose($courses);
}
else {
throw new Exception('file not found.');
}
}
catch (Exception $e){
echo "Sorry, ", $e->getMessage(), "<br>";
}
?>
data file
420-123, Web Interface Design, Jennifer Liutec
420-121, Computer Fundamentals, Amin Ranj Bar
420-122, Introduction to Programming, Samia Ramadan
420-221, Programming with Java, Samia Ramadan
420-224, Configuring and Maintaining Computers, Samia Ramadan
420-222, Web Site Planning and Implementation, Jennifer Liutec
420-223, Operating Systems and Scripting, Soumaya Chaffar
my script(trying)
$(document).ready(function(){
$("#go").click(function () {
$('#courseInfo').text();
});
});