Help please, I am very new to PHP and Java, I have been asked to make a time card page for our employees to enter there times daily. I made a form that uses Java to dynamically generate the required time card questions.. “Job Number, Drawing Number, Work Step, Quantity and Time spent.” At the push of a button. So the employee can add one job or many if needed. I got that part to work. Now the problem I run in to is I need to have a Selection box for “Job Number” and “Work Step” dynamically populated from a PHP query of the data base. So as we add / remove Job Numbers or Work Steps thay show up on the fly so I don’t have to up date the code ever time a change is made.
Here is my java code. Warning it’s sloppy; it adds two sets of tables with the questions needed. I put <!!!!DYNAMIC SELECT BOX HERE!!!!> where I would like the PHP results to be.
function addInput(divName, inputType){
var newdiv = document.createElement('div');
newdiv.innerHTML = "<table width='632' border='1'><td width='30%'><table width='307' height='129' border='1'><tr><td width='49%'><strong>Job Number:</strong></td><td width='51%'><input type='text' name='JobNumber[]'></td></tr><tr><td><strong>Drowing Number:</strong></td><td><input type='text' name='DrowingNumber[]'></td></tr><tr><td><strong>Work Step:</strong></td><td> <!!!!DYNAMIC SELECT BOX HERE!!!!> </td></tr><tr><td><strong>Quantity:</strong></td><td><input type='text' name='Quantity[]'></td></tr><tr><td height='23'><strong>Time:</strong></td><td><input type='text' name='Time[]'></td></tr></table></td><td width='70%'><table width='308' height='129' border='1'><tr><td width='49%'><strong>Job Number:</strong></td><td width='51%'><input type='text' name='JobNumber[]'></td></tr><tr><td><strong>Drowing Number:</strong></td><td><input type='text' name='DrowingNumber[]'></td></tr><tr><td><strong>Work Step:</strong></td><td><!!!!DYNAMIC SELECT BOX HERE!!!!> </td></tr><tr><td><strong>Quantity:</strong></td><td><input type='text' name='Quantity[]'></td></tr><tr><td height='23'><strong>Time:</strong></td><td><input type='text' name='Time[]'>";
document.getElementById(divName).appendChild(newdiv);
counter++;
Here is my PHP code:
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT DISTINCT name FROM work_steps where active='1' ORDER BY name";
$result = mysql_query($query);
<? print "<SELECT class='element select medium' name=Work Step size=10>";
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "<OPTION value='$value'";
}
print ">$value</OPTION>";
}
mysql_close($link);
print "</SELECT>";?>
Now both by them self work but I need help getting them to work to gather. Or if you know a better way.