I really need help with this. This code is composed of 4 drop down boxes and 3 text boxes.
It is arranged as:
1. division: which is a drop down box
2. project1: which is a drop down box
3. pcode: which is a text box
4. activity1: which is a drop down box
5. acode: which is a text box
6. medium1: which is a drop down box
7. mcode: which is a text box.
If the i have to choose 1st from the 1st drop down which is the division before I could choose from project1 then to activity1 then medium1.This is what the drop down box does. The code is fine for the drop down boxes but my very big problem is the 3 text boxes. I don't know what would be the code for the pcode, acode and mcode textbox. The data of the pcode will depend what is choosen from the project1 same also with the acode and activity1 & mcode and medium1. I colored green all the code for my textbox. If you will notice it is incomplete since I really don't know how to do it. I'm a newbie.
Hope someone could help me with this. I would appreciate it a lot. Maybe I think there should be a javascript function or php to do this but i really don't have any idea how to do this.
here is my database
DivisionTable
div_id | div_name
---1 | GIS
---2 | GAD
---3 | IT
ProjectTable
project_id | project_div_id | project_name | project_code
---------1 | ------1 ------- | -- urban | 2004P066
---------2 | ------1 ------- | --filtering | 2004P069
---------3 | ------2 ------- | -- gad work | 8200P001
---------4 | ------2 ------- | --accounting | 8200P002
---------5 | ------3 ------- | -- programming| 8100P005
---------6 | ------3 ------- | -- hardware | 8100P007
ActivityTable
project_id | activity_div_id | activity_name | activity_code
---------1 | ------1 ------- | -- Basemapping | 2004P066
---------2 | ------1 ------- | --Edgematch | 2004P069
---------3 | ------2 ------- | -- Bookkeeping | 8200P001
---------4 | ------2 ------- | --Clerical Works | 8200P002
---------5 | ------3 ------- | -- programming| 8100P005
---------6 | ------3 ------|System Administration |8100P007
MediumTable
medium ---------- | medium_code |
Working with Paper| W(P)
Working with PC---| W(PC)
<html>
<body>
<?php
mysql_connect("localhost", "root")
or die( "Unable to connect\n". mysql_error() );
mysql_select_db("TEST")
or die("Unable to select db ".mysql_error()."\n");
$seldiv = $_GET['seldiv'];
$selproj = $_GET['selproj'];
//$selact = $_GET['selact'];
echo'<form name="dropform">';
$q = mysql_query("SELECT * FROM DivisionTable");
echo"<select name=\"division\" onChange=\"Load_id()\">";
echo "<option>".""."</option>";
while($row = mysql_fetch_array($q)) {
$selected = ($row["div_id"] == $seldiv)? "SELECTED":"";
echo"<option value=\"".$row['div_id']."\"". $selected." >".$row['div_name']."</option>";
}
echo"</select>";
$q2 = mysql_query("SELECT * FROM ProjectTable WHERE project_div_id = $seldiv");
echo"<select name=\"project1\" onchange=\"Load_code()\">";
while($row = mysql_fetch_array($q2)) {
echo"<option value=\"".$row['project_id']."\">".$row['project_name']."</option>";
}
echo"</select>";
[COLOR=DarkOliveGreen]
$q2 = mysql_query ("Select * from ProjectTable where ___");
echo "<input class=textbox name=\"pcode\" value=\"".$row['project_code']."\">";[/COLOR]
$q4 = mysql_query("SELECT * FROM ActivityTable WHERE activity_div_id = $seldiv");
echo"<select name=\"activity1\" >";
while($row = mysql_fetch_array($q4)) {
echo"<option value=\"".$row['activity_id']."\">".$row['activity_name']."</option>";
}
echo"</select>";
[COLOR=DarkOliveGreen]
$q5 = mysql_query ("Select * from ActivityTable where ____");
echo "<input class=textbox name=\"acode\" value=\"".$row['activity_code']."\">";[/COLOR]
$q6 = mysql_query("SELECT * FROM MediumTable");
echo"<select name=\"medium1\" >";
echo "<option>".""."</option>";
while($row = mysql_fetch_array($q6)) {
echo"<option>".$row['Medium']."</option>";
}
echo"</select>";
[COLOR=DarkOliveGreen]
$q7 = mysql_query ("Select * from MediumTable where ____");
echo "<input class=textbox name=\"mcode\" value=\"".$row['medium_code']."\">";[/COLOR]
echo "</form>";
?>
<script type="text/javascript">
function Load_id()
{
var seldiv = document.dropform.division.options[document.dropform.division.selectedIndex].value;
var seldiv_txt = "?seldiv=";
location = seldiv_txt + seldiv;
}
</script>
</BODY>
</HTML>
😕