Hi,
I've been google'ing until Im blue in the face and think I have found a solution as to what I want to do, but I cant get how I achieve it. Would I be correct in thinking to get the selected value from below
<select name="Activity">
<?php
$sql = "SELECT Status FROM Activity";
$rs = mysql_query($sql) or trigger_error(mysql_error() . " unable to run query.");
echo "<option></option>";
while($row = mysql_fetch_assoc($rs))
{
echo "<option value=\"".$row['Activity']."\">".$row['Status']."</option>\n ";
}
?>
</select>
The array I need is "Activity"?
Do I then use javascript getelementbyid? This being the 'Activity' field how do I then push this to the Activity location in the below table? If Im doing this completely wrong would someone be so kind as to point me in the right direction please?
<button onclick='addRow();'>Add to Table</button>
<script type='text/javascript'>
function addRow(){
//get a reference to the table tbody
var myTable = document.getElementById('myTable').getElementsByTagName('TBODY')[0];
//create the table row
var tr = document.createElement('TR');
//create the 4 column cells
var td1 = document.createElement('TD');
td1.innerHTML = '<input class="name" />';
var td2 = document.createElement('TD');
td2.innerHTML = '<input class="date" />';
var td3 = document.createElement('TD');
td3.innerHTML = '<input class="name" />';
var td4 = document.createElement('TD');
td4.innerHTML = '<input class="hours" />';
var td5 = document.createElement('TD');
td5.innerHTML = '<input class="name" />';
var td6 = document.createElement('TD');
td6.innerHTML = '<input class="name" />';
var td7 = document.createElement('TD');
td7.innerHTML = '<input class="description" />';
//add the column cells to the row
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
tr.appendChild(td6);
tr.appendChild(td7);
//append the row to the table
myTable.appendChild(tr);
}
</script>
<table id='myTable'>
<thead>
<tr>
<td>Name</td>
<td>Date</td>
<td>Project</td>
<td>Hours</td>
<td>Department</td>
<td>Activity</td>
<td>Description</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
Thanks