Hello,
I am having trouble with my onchange list box. In my first list box you select a category which populates the list box below with the appropriate job types. This works fine. But the value that I selected in the first list box does not stay selected. I need this value to stay selected because when the form is complete, there will be a submit button that needs the selected information from both list boxes. Here is my code:
<HTML>
<HEAD>
<TITLE>Search Jobs</TITLE>
</HEAD>
<BODY>
<?php REQUIRE("db_3rjobs.inc");
if (isset($Select1))
{
$sql = "SELECT job_type FROM type WHERE category_id = '$Select1'";
$result = mysql_query($sql);
}
?>
<FORM>
<SELECT NAME="Select1" SIZE="1" onChange="javascript:document.forms[0].submit()">
<OPTION VALUE=http://www.webdeveloper.com/forum/archive/index.php/"">-- please select --</OPTION>
<OPTION value="2">Teaching, Professor
<OPTION value="3">Teaching, Middle/High School
<OPTION value="4">Teachgin, Elementary
<OPTION value="5">Teaching, Special Ed
<OPTION value="7">Administrative, Management
</SELECT><BR>
</FORM>
<FORM>
<SELECT NAME="Select2" SIZE="5">"
<?php
while ($row = mysql_fetch_row($result))
{
foreach ($row as $field)
{
print "<OPTION value='$field'";
print ">$field</OPTION>";
}
}
?>
</SELECT>
</FORM>
</body>
</html>
I am having trouble with my onchange list box. In my first list box you select a category which populates the list box below with the appropriate job types. This works fine. But the value that I selected in the first list box does not stay selected. I need this value to stay selected because when the form is complete, there will be a submit button that needs the selected information from both list boxes. Here is my code:
<HTML>
<HEAD>
<TITLE>Search Jobs</TITLE>
</HEAD>
<BODY>
<?php REQUIRE("db_3rjobs.inc");
if (isset($Select1))
{
$sql = "SELECT job_type FROM type WHERE category_id = '$Select1'";
$result = mysql_query($sql);
}
?>
<FORM>
<SELECT NAME="Select1" SIZE="1" onChange="javascript:document.forms[0].submit()">
<OPTION VALUE=http://www.webdeveloper.com/forum/archive/index.php/"">-- please select --</OPTION>
<OPTION value="2">Teaching, Professor
<OPTION value="3">Teaching, Middle/High School
<OPTION value="4">Teachgin, Elementary
<OPTION value="5">Teaching, Special Ed
<OPTION value="7">Administrative, Management
</SELECT><BR>
</FORM>
<FORM>
<SELECT NAME="Select2" SIZE="5">"
<?php
while ($row = mysql_fetch_row($result))
{
foreach ($row as $field)
{
print "<OPTION value='$field'";
print ">$field</OPTION>";
}
}
?>
</SELECT>
</FORM>
</body>
</html>