Script de listas desplegables

¿Cómo agrego una matriz de valores a este javascript para que los incluya en las listas desplegables? Llegué tan lejos y estoy realmente atascado, creo que debe ser una pequeña adición a JavaScript.

Cualquier ayuda sería genial.

JAVASCRIPT var counter = 0; function addNew() { // Get the main Div in which all the other divs will be added var mainContainer = document.getElementById('mainContainer'); // Create a new div for holding text and button input elements var newDiv = document.createElement('div'); // Create a new text input var newText = document.createElement('select'); newText.type = "select"; //for testing newText.value = counter++; // Create buttons for creating and removing inputs var newAddButton = document.createElement('input'); newAddButton.type = "button"; newAddButton.value = " + "; var newDelButton = document.createElement('input'); newDelButton.type = "button"; newDelButton.value = " - "; // Append new text input to the newDiv newDiv.appendChild(newText); // Append new button inputs to the newDiv newDiv.appendChild(newAddButton); newDiv.appendChild(newDelButton); // Append newDiv input to the mainContainer div mainContainer.appendChild(newDiv); // Add a handler to button for deleting the newDiv from the mainContainer newAddButton.onclick = addNew; newDelButton.onclick = function() { mainContainer.removeChild(newDiv); }; } 

HTML

  t1 t2 t3   

EDITAR PHP

  <?php $name = $_POST['name']; $email = $_POST['email']; $number = $_POST['number']; $Occasion = $_POST['Occasion']; $Venues = $_POST['Venues']; $date = $_POST['date']; $guests = $_POST['guests']; $custom = $_POST['custom']; $from = $email; $to = 'ash.manterfield@btinternet.com'; $subject = 'New Menu Order'; $human = $_POST['human']; $body = "From: $name\n Contact Number: $number\n E-Mail: $email\n Occasion: $Occasion\n Venues Looked At: $Venues\n Event Date: $date\n Number of Guests: $guests\n Custom Menu:\n $custom"; if ($_POST['submit']) { if ($name != '' && $email != '') { if ($human == '4') { if (mail ($to, $subject, $body, $from)) { echo '

Your message has been sent!

'; } else { echo '

Something went wrong, go back and try again!

'; } } else if ($_POST['submit'] && $human != '4') { echo '

You answered the anti-spam question incorrectly!

'; } } else { echo '

You need to fill in all required fields!!

'; } } ?>

Aclamaciones

Para obtener los valores del cuadro de selección anterior. Agregue el siguiente código justo después de la function addNew() {

 function addNew() { var countAll = document.getElementsByTagName("select").length - 1; var lastSelectBox = document.getElementsByTagName("select")[countAll]; var items = lastSelectBox.innerHTML; 

Aquí obtengo el último cuadro de selección creado en el documento.

Y agrega un nuevo html de items después de:

 var newText = document.createElement('select'); newText.type = "select"; //Attribute Name use for form elements newText.setAttribute('name', 'text['+counter+']'); //Attribute id newText.setAttribute('id', 'text_' + counter); newText.innerHTML = items; 

Puedes ver trabajar jsfiddle