EDIT QUESTION: In my WHILE loop, it creates an readonly input text box, and the values are whatever records it pulls from my Database. After each text box, there is an add button, which is suppose to append the value of the text box beside the button, to another div on my page. The only value being added is the first record. I know why, I just can't fix. Any ideas?
$query = "SELECT `$posResults` FROM test.departments ";
$result = mysql_query($query);
if ($result) {
//output results from database
echo 'Software';
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><input type="text" id="rSoft" size="50" name="reqSoft" value="'.$row[0].'" readonly/> <button id="toForm" value="Add" >Add</button>';
echo '</td>';
echo '</tr>';
}
echo "<script type='text/javascript'>$(document).ready(function(){ $('button#toForm').click(function(){ var req = document.getElementById('rSoft').value; $('<tr><td>' + req + '</td></tr>').appendTo('#empInfo');}); });</script>";
}
Here is an image. When I Hit Add, I want the value to go to the div. Right now, only the first value is being appended.
