Formulario dinamico [quase bom]

0 respostas
renato_ramos

oi ^^"

consegui fazer os inputs … agora eh soh editar as posições na tela… segue o codigo:

script

var id = 1;
function novoCampo(){

    var inp = document.createElement("input");
    inp.setAttribute("id", id );
    var lab = document.createElement("label");
    lab.setAttribute("id", "l"+id);
    var lab_content = document.createTextNode("Campo de Texto " + id + " ");
    var quebra = document.createElement("br");
    lab.appendChild(lab_content);
    var inpP = document.getElementById(id-1);
    var parentInp = inpP.parentNode;
    parentInp.insertBefore(lab, inpP.nextSibling);
    parentInp.insertBefore(inp, lab.nextSibling);
    parentInp.insertBefore(quebra, lab);
    ++id;
}

jsp

<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
        <webuijsf:page id="page1">
            <webuijsf:html id="html1">
                <webuijsf:head id="head1">
                    <webuijsf:script url="GeraAlternativa.js"/>
                </webuijsf:head>
                <webuijsf:body id="body1" style="-rave-layout: grid">
                    <webuijsf:form binding="#{cadastro_questao.formQuestao}" id="formQuestao">
                        <webuijsf:textField binding="#{cadastro_questao.textFieldQuestao}" columns="50" id="textFieldQuestao" style="left: 96px; top: 72px; position: absolute"/>
                        <webuijsf:label id="label1" style="left: 24px; top: 72px; position: absolute" text="Questão:"/>
                        <webuijsf:button actionExpression="#{cadastro_questao.buttonSalvar_action}" id="buttonSalvar"
                            style="height: 24px; left: 551px; top: 72px; position: absolute; width: 96px" text="Salvar"/>
                        <input id="0" name="textfield" style="left: 144px; top: 120px; position: absolute" type="text"/>
                        <input name="Submit" onclick="novoCampoImplicito();return false;" style="left: 288px; top: 120px; position: absolute" type="submit" value="+ 1 Campo"/>
                    </webuijsf:form>
                    <webuijsf:form binding="#{cadastro_questao.formAlternativa}" id="formAlternativa"
                        style="height: 216px; left: 96px; top: 168px; position: absolute; width: 456px" visible="false">
                        <input id="0" name="textfield" style="left: 144px; top: 120px; position: absolute" type="text"/>
                        <input name="Submit" onclick="novoCampoImplicito();return false;" style="left: 288px; top: 120px; position: absolute" type="submit" value="+ 1 Campo"/>
                    </webuijsf:form>
                </webuijsf:body>
            </webuijsf:html>
        </webuijsf:page>
    </f:view>
</jsp:root>

mt obrigado ^^’

e estou aberto a criticas e sugestoes =D

Criado 14 de outubro de 2009
Respostas 0
Participantes 1