'use strict';

var choiceId = 2; // used by the addChoice() function to keep track of IDs

function addElement(parentId, elementTag, elementId, html) {
    // Adds an element to the document
    var p = document.getElementById(parentId);
    var newElement = document.createElement(elementTag);
    newElement.setAttribute('id', elementId);
    newElement.innerHTML = html;
    p.appendChild(newElement);
}

function addChoice() {
    choiceId++; // increment fileId to get a unique ID for the new element
    var html = '<input type="text" onclick="javascript:removeElement(choice' + choiceId + '); return false;">Remove</input>';
    addElement("createpoll", 'button', 'choice' + choiceId, html);
};



@@ -401,16 +401,198 @@
 nt);%0A%7D%0A%0A
+function removeElement(elementId) %7B%0A    // Removes an element from the document%0A    var element = document.getElementById(elementId);%0A    element.parentNode.removeChild(element);%0A%7D%0A%0A
 function
@@ -715,16 +715,71 @@
 e=%22text%22
+ id = %22choice%22' + choiceId + '%3E %3Cbutton type = %22button%22
  onclick
@@ -853,21 +853,22 @@
 Remove%3C/
-input
+button
 %3E';%0A    

add poll choices