TySkby 41 Junior Poster

So I'm having a heck of a time getting this to work- JavaScript isn't exactly my specialty and I realize that's a big part of the issue, but I'm at my wit's end...

I'm developing a PHP application that deals with scheduling music lessons.
In my application, I have these two variables that I use a lot for filling <select> lists:

$instrument_list = <option value='Guitar'>Guitar</option><option value='Piano'>Piano</option>;
$teacher_list = <option value='Fake McTest'>Fake McTest</option<option value='John Smith'>John Smith</option>

My problem is that there is one form in my application where I would like have two <select> lists...
The first list is static:

<select name='filter' id='filter' onchange='update_filter()'>
<option value=' '>Select</option>
<option value='instrument'>Instrument</option>
<option value='teacher'>Teacher</option>
</select>

The second list is dynamic (but still client-side):

<select name='search_term' id='search_term'>
</select>

Since my php variable is already filled with the proper HTML, I just need a way to get javascript to place the $instrument_list or $teacher_list within the second list's <select> tags. So far I've had no luck.

If anyone had any suggestions or ideas on how to go about doing this, I would be forever grateful. I've tried out a few various renditions of javascript function, but none have worked so far. At the bottom of this post I'll paste the <script> stuff that I've been using if the reference is helpful, but it doesn't seem to be doing me much good.

Thanks a bunch,
Ty

This is the latest javascript I've tried (since I'm using PHP, the \ marks are necessary, I believe):

<script language='javascript'>
     function update_filter() {
          var inst = \"$instrument_options\";
          var teach = \"$teacher_options\";
          if(document.getElementById('viewsched_filter').value == 'instrument') {
               document.getElementById('search_term').innerHTML = inst;
          }
          if(document.getElementById('viewsched_filter').value == 'teacher') {
               document.getElementById('search_term').innerHTML = teach;
		}
     }
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.