Dynamic table

Asked

Viewed 126 times

2

Friends, I need to create a dynamic table in HTML and Javascript that will work as follows:

I have a series of items in a Combobox and when selecting, creates a column in a table. After, I add another Combobox, where I select another item and after this item creates another column in the Table.

The following is an example attached.

Please, could someone help me?

Thank you very muchinserir a descrição da imagem aqui

  • 1

    Do you have any code of your attempts to show?

1 answer

1

You can apdatate this code for your use:

<select class="input-xxlarge empresaRegistro" name="empresaRegistro" id="empresaRegistro" style="width: 715px !important;" onChange="getFuncionario()">
    <option value="">Selecione a Empresa</option>
    <?
        foreach($lista_cedente as $valor){
    ?>
        <option value="<? echo $valor->idCedente; ?>"><? echo $valor->razaosocial; ?></option>
    <? } ?>
</select>

Script jQuery:

<script>
        function getFuncionario() {
            var id = $('#empresaRegistro').val();
            $(".idFuncionarioLista").append('<option value="0">Carregando...</option>');
            $.post("<? echo base_url(''); ?>proventos/ajax/funcionario/"+id,
                {idFuncionarioLista:jQuery(id).val()},
                function(valor){
                     $(".idFuncionarioLista").html(valor);
                }
            );
        }

</script>

In this scheme: When you select the Registration Company (Company field), I enter the ajax and search all the data and list them below in a next field select also called idFunctionshipList. You can do the same type of jquery to search for the next select, then using onchange="NAMESENCUNCAO()" in select idFunctionaryList for example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.