I need a same form with 2 buttons to send to different places

0

Good night guys, I have a little problem I have a foreach that loads several cards on a page, each card has a modal with its card information, Modals are loaded from same way as the card, I need one of the buttons to update the patient information and another one from a delete button, they worked when the cards were fixed but after I collected dynamics in the page the buttons did not work anymore, try changing the id, value, name, but nothing was good, can anyone help me?

Follow the JS code used earlier to change the mod and follow the modal form code

$(document).on('click', '#alterar', function() {
    $(this).attr("id","salvar").html("Salvar");
    $(this).attr("onclick","myFunction()").html("Salvar");
});
$(document).on('click', '#salvar', function() {
    $(this).attr("id","alterar").html("Alterar");
    $(this).attr("type","submit").html("Salvar");
    $(this).attr("value","enviar").html("Salvar");

});
   $(document).on('click', id, function () {
        document.getElementById(id).disabled = false;
        document.dadosPaciente.action = "formsDB/Delete.php";
        document.dadosPaciente.submit();

    });



function disableField() {
    document.getElementById(id).disabled = true;
}

function undisableFieldset() {
    document.getElementById(id).disabled = false;
}

function HabCampos() {
    if (document.getElementById('medico').checked) {
        document.getElementById('form_medico').style.display = "";
        document.getElementById('form_enfermeiro').style.display = "none";
        document.getElementById('text').focus();

    }  if (document.getElementById('enfermeiro').checked){
        document.getElementById('form_medico').style.display = "none";
        document.getElementById('form_enfermeiro').style.display = "";
        document.getElementById('text').focus();
    }}

function desabilita_a(){

    document.getElementById('form_enfermeiro').style.display = "none";
    document.getElementById('form_medico').style.display = "none";
}
      <!-- Inicio Modal view/update paciente -->
<div class="modal fade" id="modalView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
     aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content mb-0">
            <div class="modal-header">
                <h3 class="modal-title" id="modalViewTitle">Visualisar paciente </h3>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body mb-0">
              <form id="dadosPaciente" onchange="this.form.submit();" name="dadosPaciente" method="post">
                    <fieldset id="camada" disabled>
                        Numero do Paciente :<br>
                        <input class="form-control" type="number" name="numero_paciente" value="'.$resultado[$i]['numero_paciente'].'" readonly/>
                        <br>Nome do paciente:<br>
                        <input class="form-control" type="text" name="nome_paciente" value="'.$resultado[$i]['nome_paciente'].'" readonly/>
                        <br>Data de Internação :<br>
                        <input class="form-control" type="date" name="dtInter_paciente" value="'.$resultado[$i]['dtInter_paciente'].'" readonly/>
                        <br>Tempo de gravidez: <br>
                        <input class="form-control" type="number" name="dtParto_paciente"
                              placeholder="'.$resultado[$i]['dtParto_paciente'].' semanas"/>
                        <br>Classificação de Robson: <br>
                        <select class="custom-select mr-sm-1" name="clasRob">
                            <option value="">'.$rob.'</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                        </select><br>
                        <br>Tipo Internação : (Anteparto, Parto, Pós-parto)<br>
                        <select class="custom-select mr-sm-1" name="TipoInter">
                            <option value="">{TIPOPARTOMODAL0}</option>
                            <option value="Anteparto">Anteparto</option>
                            <option value="Parto">Parto</option>
                            <option value="pos">Pós-Parto</option>
                        </select>
                        <br><br>Admissão obstétrica (TP espontâneo, TP induzido, Sem TP)<br>
                        <select class="custom-select mr-sm-1" name="adimis">
                            <option value="{TP0}"></option>
                            <option value="Espontâneo">Espontâneo</option>
                            <option value="Induzido">Induzido</option>
                            <option value="Sem TP">Sem Tp</option>
                        </select>
                        <br><br>Risco Gestacional (risco habitual e alto risco)<br>
                        <select class="custom-select mr-sm-1" name="risco">
                            <option value=""></option>
                            <option value="Habitual">Habitual</option>
                            <option value="Alto Risco">Alto Risco</option>
                        </select>
                        <br><br>Transfusão (sim ou não)<br>
                        <label for="sim">Sim</label>
                        <input type="radio" name="tranfu" id="sim" value="Sim" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <label for="não">Não</label>
                        <input type="radio" name="tranfu" id="não" value="Não" />
                        <br><br>Evento adverso (se teve ou não - detalhar)<br>
                        <font size="1" face="arial, helvetica, sans-serif"> ( Limite de 1000 caracteres. )<br>
                            <textarea class="form-control" wrap="physical" name="message" rows="5" cols="30"
                                      onKeyDown="textCounter(this.form.message,this.form.remLen,1000);"
                                      onKeyUp="textCounter(this.form.message,this.form.remLen,1000);"></textarea>
                            faltam&nbsp;<input readonly type=text name=remLen size=1 maxlength=1 value="1000"
                                               style="border: none;width: 30px;"><br></font><br>
                    </fieldset>
                        <div class="modal-footer mb-0">
                          <button type="button" value="alta" id="alta" class="float-left btn btn-success">Alta
                          </button>
                            <button onclick="disableField()" type="button" class="btn btn-secondary"
                                    data-dismiss="modal">Fechar
                            </button>
                            <button onclick="undisableFieldset();" value="up" type="button" class="btn btn-primary"
                                    id="alterar">Alterar</button>
                        </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- Fim Modal view/update paciente -->
    
asked by anonymous 17.06.2018 / 00:01

0 answers