I tried to populate a drop down based on another drop down with JavaScript, for example: I have 2 Select tags
[code]
<option value=" " selected="selected"> </option>
<option value="1">Web Developers</option>
<option value="2">Programmers</option>
<option value="3">another one</option>
Please select one of the Department above first
[/code]
…
I tried to populate a drop down based on another drop down with JavaScript, for example: I have 2 Select tags
<option value=" " selected="selected"> </option>
<option value="1">Web Developers</option>
<option value="2">Programmers</option>
<option value="3">another one</option>
Please select one of the Department above first
so , when I choose a department (e.g, [php]web developers[/php]) I’m getting data from a table (web) that contains students name.
I have the following code:
[php]function setOptions(chosen) {
var selbox = document.myform.opttwo
var list2 = document.form1.students
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the Department above first',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('get web Developers name from web table');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = ne Option('get programmers name from prog table');
}
if (chosen == "3") {
selbox.options[selbox.options.length] = new Option('get another name from another table');
}
}
[/php]
I tried to add
[php]<?php
$result =“SELECT web_student_name FROM web”;
while($row = mysql_fetch_array($result))
{
echo $row[‘web_student_name’] ."
";
}
?> [/php]
but it doesn’t work correctly and I can’t tell why.
What should I put HERE > [php](‘get web Developers name from web table’);[/php]?