
<script type="text/javascript">
    var textNumber = 2;
    function addTextBox(form, afterElement) {
    // Increment the textbox number
    textNumber++;
    // Create the label
    var label = document.createElement("label");
    // Create the textbox
    var textField = document.createElement("input");
    textField.setAttribute("type","text");
    textField.setAttribute("name","vote_option");
    textField.setAttribute("id","content"+textNumber);
    // Add the label's text
    label.appendChild(document.createTextNode("选项: "));
    // Put the textbox inside
    label.appendChild(textField);
    // Add it all to the form
    form.insertBefore(label,afterElement);
    return false;
   }
   function removeTextBox(form) {
     if (textNumber > 2) { // If there's more than two text box
     // Remove the last one added
        form.removeChild(document.getElementById("content"+textNumber).parentNode);
        textNumber--;
     }
   }
</script>

<div class="bjui-pageContent">

        <form action="${ctxPath}/cms/vote/saveOption" id="option_form" method="post" data-toggle="validate" data-autorefresh="true" data-alertmsg="false">

            <input type="hidden" id="flag" name="flag" value="${flag}">
            <input type="hidden" id="xh" name="xh" value="${xh}">
            <h3 class="form-signin-heading">请创建投票选项:</h3>

            @for(op in opList){
            @var textNumber = 0;
            @textNumber++;
            <label>选项: <input type="text" name="vote_option" value="${op.content!}" id="content"+textNumber/></label>
            @}

            <div class="text-center">
                <button type="submit" class="btn btn-green" value="保存">&nbsp;保&nbsp;存&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-green" onClick="addTextBox(this.form,this.parentNode)">增加选项</button>&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-red" onClick="removeTextBox(this.form)">删除选项</button>
            </div>

        </form>

</div>
