From: master44 on
I am looking for a way to dynamically and repeatedly add a dropdown
list to a form populated with data from a mysql query:

So for example I have a php/mysql query:
SELECT * FROM fruits;

Which returns an array:
fruits('apple','bananna','pear','cherry');

Now I have a form with among other elements an add button and when
clicked creates a dropdown with a list of fruits from the php/mysql
array above.

I came up with the following which adds a new text field, but need to
modify it to accept an array from php/mysql to create the dynamic
dropdowns:

<script type='text/javascript'>
var counter = 0;
var limit = 3;
function addInput(divName){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + "
inputs");
}
else {
var newdiv = document.createElement('div');
newdiv.innerHTML = "Entry " + (counter + 1);
newdiv.innerHTML += " <br><input type='text' value='<?php echo
$counter; ?>' name='myInputs[]'>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}
</script>

<form method="POST">
<div id="dynamicInput"></div>
<input type="button" value="Add text input" onClick="addInput
('dynamicInput');">
</form>

Any ideas??