I’m really stuck. What I’m trying to do is have a drop down list of courses for a given term. Below the 5 selection lists is 5 default images. When a course is chosen, I’d like the corresponding image to change to show that course’s information. I don’t want to write a function for each drop down, but have one function to handle all 5 changes.
This is the function that writes the selection list to the page…
function writeFall1() {
document.write(‘<select name=”year1fall”‘ + year1FallCourses + ‘ onChange=”stuff here>’);
document.write(‘<option>Choose a course…</option>’);
//start the filtering of all the CIS courses available for this term
for (i = 0; i < courseList.length; ++i) {
if ( courseList[i].f == “y” ) {
document.write(‘<option value=’ + courseList[i].id + ‘>’ + courseList[i].id + ‘ </option>’);
document.write(courseList[i].id + ” ” + courseList[i].title);
}
}
document.write(‘</select> ’);
//increase this variable so that each selection box corresponds to one image field
year1FallCourses++;
}
This is the attempted image change function, just writing to the site to see what values i’m getting…
function changeImage(courseID, formID) {
document.write(courseID + ” ” + formID);
document.write(document.year1fall1.options);
}
If it helps, the html for this…
<img name=”year1fall1″ src=”images/default.jpg”>
<img name=”year1winter1″ src=”images/default.jpg”>
<img name=”year1spring1″ src=”images/default.jpg”>
<img name=”year2fall1″ src=”images/default.jpg”>
<img name=”year2winter1″ src=”images/default.jpg”>
<img name=”year2spring1″ src=”images/default.jpg”>
… so those appear horizontally. Going down, its “year1fall2”, “year1fall3” etc. to differentiate between the course selections.
It feels like i’m so close! Any help is much appreciated!