Pass ID by parameter in modal window

Asked

Viewed 3,336 times

0

I wanted to know how I can pass parameter o ID from a user to a modal window using php. I’m using the bootstrap to use his modal.

In this window would open a form with customer information, so it can be changed and saved again.


Close-up New Client

    <div class="modal-body">
      <form class="formClient" action="includes/_cadCliente.php" method="post">
            <div class="col-xs-4">
                <div class="form-group">
                    <label for="nome">Nome*:</label>
                    <input type="text" class="form-control" id="nome" name="nome">
                </div>

                <div class="form-group">
                <label for="email">E-mail*:</label>
                <input type="text" class="form-control" id="email" name="email">
                </div>

                <div class="form-group">
                <label for="Endereco">Endereço*:</label>
                <input type="text" class="form-control" id="Endereco" name="endereco">
                </div>

                <div class="form-group">
                <label for="Cidade">Cidade*:</label>
                <input type="text" class="form-control" id="Cidade" name="cidade">
                </div>

                <div class="form-group">
                <label class="checkbox-inline">
                  <input type="checkbox" name="campanhaEmail" id="inlineRadio2" value="sim"> Permitir campanhas de e-mail
                </label>
                </div>
            </div>

            <div class="col-xs-4">
                <div class="form-group">
                    <label for="nomeCliente">Data de Aniversário*:</label>
                    <input type="text" class="form-control" id="nomeCliente" name="aniversario">
                </div>

                <div class="form-group">
                <label for="nomeCliente">Celular:</label>
                <input type="text" class="form-control" id="nomeCliente" name="celular">
                </div>

                <div class="form-group">
                <label for="nomeCliente">Bairro:</label>
                <input type="text" class="form-control" id="nomeCliente" name="bairro">
                </div>

                <div class="form-group">
                <label for="estado">Estado:</label>
                <select name="estado" id="estado" class="form-control">
                    <option value="">Selecione um estado</option>
                    <option value="ac">Acre</option>
                    <option value="al">Alagoas</option>
                    <option value="ap">Amapá</option>
                    <option value="am">Amazonas</option>
                    <option value="ba">Bahia</option>
                    <option value="ce">Ceará</option>
                    <option value="df">Distrito Federal</option>
                    <option value="es">Espirito Santo</option>
                    <option value="go">Goiás</option>
                    <option value="ma">Maranhão</option>
                    <option value="ms">Mato Grosso do Sul</option>
                    <option value="mt">Mato Grosso</option>
                    <option value="mg">Minas Gerais</option>
                    <option value="pa">Pará</option>
                    <option value="pb">Paraíba</option>
                    <option value="pr">Paraná</option>
                    <option value="pe">Pernambuco</option>
                    <option value="pi">Piauí</option>
                    <option value="rj">Rio de Janeiro</option>
                    <option value="rn">Rio Grande do Norte</option>
                    <option value="rs">Rio Grande do Sul</option>
                    <option value="ro">Rondônia</option>
                    <option value="rr">Roraima</option>
                    <option value="sc">Santa Catarina</option>
                    <option value="sp">São Paulo</option>
                    <option value="se">Sergipe</option>
                    <option value="to">Tocantins</option>
                </select>
                </div>

                <div class="form-group">
                <label class="checkbox-inline">
                  <input type="checkbox" name="campanhaSms" id="inlineRadio2" value="sim"> Permitir campanhas de sms
                </label>
                    </div>
            </div>

            <div class="col-xs-4">
                <div class="form-group">
                <label for="nomeCliente">Sexo*:</label>
                <select name="sexo" id="estado" class="form-control">
                    <option value="Masculino">Masculino</option>
                    <option value="Feminino">Feminino</option>
                </select>
                </div>

                <div class="form-group">
                <label for="Email">Telefone*:</label>
                <input type="text" class="form-control" id="Email" name="telefone">
                </div>

                <div class="form-group">
                <label for="Endereco">Como conheceu?</label>
                <input type="text" class="form-control" id="Endereco" name="conheceu">
                </div>

                <div class="form-group">
                <label for="Cidade">Observação</label>
                <textarea class="form-control" rows="5" name="observacao"></textarea>
                </div>
            </div>

            <div class="bar-button">
                <button class="btn btn-default" data-dismiss="modal">Cancelar</button>
                <button type="submit" class="btn btn-success">Salvar</button>
            </div>
        </form>
    </div>
</div>

  • show the code you are using

  • What exactly? From modal? Is that I’m using bootstrap to call the modal....

  • yes, the modal with the form you mentioned

  • Okay, only HTML does it? I didn’t put JS because I don’t know exactly which part to put...

  • This modal is to load user information dynamically with AJAX or load the information directly into the page load?

  • It is a customer list and will have a button to edit the information, once the button is clicked, this modal is opened with the information of that customer, which will be selected by his ID.

  • tested my answer?

Show 2 more comments

1 answer

2


a simple example

$.ajax({
  url: "cliente.php?id=123",
}).done(function( content ) {
  // LOAD MODAL( content )!!!
});


php client.
use $_GET["id"] to query user data and return information

Browser other questions tagged

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