-2
I have the following form
<form method='post' name='checkbox_form' id='checkbox_form' onsubmit='return validate()' action=''>
..............
..............
<input name='salvar' type='submit' value='Salvar'>
<input name='gravar' type='submit' value='Gravar'>
</form>
and in PHP, depending on the button clicked, the variable $pasta
takes proper value correctly.
if (isset($_POST["gravar"])||isset($_POST["gravar2"])){
$pasta="favoritas/";
}else{
$pasta="usuario/";
}
In addition it has two buttons that will, in a given situation, appear within a modal
<div style=\"display:none\">
<div id=\"ajax2\" class=\"ajax2\">
<input name='salvar2' type='button' id='salvar' value='Salvar'>
<input name='gravar2' type='button' id='gravar' value='Gravar'>
</div>
</div>
To submit the form with the modal buttons I used the following script:
$("#salvar").click(function() {
$("#checkbox_form").submit();
});
$("#gravar").click(function() {
$("#checkbox_form").submit();
});
The problem: whatever the button clicked on the modal the variable $pasta
takes on the value usuario/
of condition else
PHP, that is, no isset
The question: How can I execute the conditional in PHP correctly by clicking on the modal buttons?
A possibility would be instead of button in the modal, to <label for="id_do_botao> - When you click on a label for, the button is triggered (it is a kind of "remote control"). Ai would be the case to style the label to look like button (I’m presenting as quick solution, obviously someone can post something more elaborate with JS and real button)
– Bacco
As I recall, PHP will only be able to do this comparison on type buttons
submit
. That is, by clicking ongravar2
he won’t be able to recover.– Don't Panic
@Everson the clicked <button> also sends its value. (Just what was clicked, practically like Submit).
– Bacco
For those who only know how to vote negative will a publication of
dvd
pra vcs https://chat.stackexchange.com/rooms/75640/votos-negativos-sem-explicacao Rethink and try to be more helpful!– user60252
It’s crossed my mind now to just put a form in the modal and end of conversation!
– user60252