Ok, I am trying to populate two drop down boxes with the results of a query. I have the first one set up and working but I am stuck on how to pass the results of the first query as a constraint for the second as there is no submit and every example I can find on the web only shows how to pass via post/get into another page. :mad:
Here is what I have for code:
Below are the functions that display the results of the query in a table.
-
function dd_joblist($user_name)
-
{
-
$result=mysql_query("SELECT DISTINCT job_name FROM oats_jobs_users_laborCode where user='$user_name' order by job_name;");
-
if($result)
-
{
-
echo "<select name=\"job_select\" onchange=\"$job_select=reload(this.form)\"> <option default=\"default\" value=\"*\">Choose One</option>";
-
while($row=mysql_fetch_row($result))
-
{
-
echo "<option value=\"$row[0]\">$row[0]</option>";
-
}
-
echo "</select>";
-
}
-
else
-
{
-
echo mysql_error($result);
-
}
-
}
-
-
function dd_laborlist($user_name, $job_select)
-
{
-
$result=mysql_query("SELECT DISTINCT labor_code FROM oats_jobs_users_laborCode where user='$user_name' and job_name='$job_select' order by job_name;");
-
if($result)
-
{
-
echo "<select name=\"laborcode\" > <option default=\"default\" value=\"\">Choose One</option>";
-
while($row=mysql_fetch_row($result))
-
{
-
echo "<option value=\"$row[0]\">$row[0]</option>";
-
}
-
echo "</select>";
-
}
-
else
-
{
-
echo mysql_error($result);
-
}
-
}
-
This is a js that is (hopefully) reloading the page and seems to be storing the first value.
-
function reload(form)
-
{
-
var val=form.job_select.options[form.job_select.options.selectedIndex].value;
-
self.location='options_screen.inc.php?job_select=' + val ;
-
return val;
-
}
-
This is the HTML code that calls the php functions
-
<td><?php dd_joblist($user_name) ?></td>
-
<td><?php dd_laborlist($user_name, $job_select) ?></td>
-
I am almost to the point of pulling my hair out. Any help would be greatly appreciated