0
This is a Javaweb project, but I’m already getting the value from the button when you click on it.
Every time I click the eclipse IDE button I was able to print the value of the button, if I click it, it returns a false, if you click again on the button it returns true
I need an algorithm that when clicking the button it shows pause and when you click again it shows initiate
This is the HTML
<div class="panel-body" >
<div class="btn-group" role="group" aria-label="...">
<c:if test="${suspenso == false}">
<button id="pausar" type="button" class="btn btn-primary" title="Pausar" onclick="pausar();">Pausar</button>
</c:if>
<c:if test="${suspenso != false}">
<button id="pausar" type="button" class="btn btn-primary" title="Pausar" onclick="pausar();">Iniciar</button>
</c:if>
</div>
</div>
I tried that;
function pausar(){
$(document).on('click', '#pausar', function() {
$("#status").html("mudando o nome do botão para botao2");
$(this).attr("id","botao2").html("BOTÃO 2");
});
$(document).on('click', '#pausar', function() {
$("#status").html("retornando o nome do botão para botao1");
$(this).attr("id","botao1").html("BOTÃO 1");
});
document.forms[1].action = "AdministracaoRemessa!pausar";
document.forms[1].submit();
}
It would be good if it were done in Ajax, because you wouldn’t have to reload the page.
Gives a search for "ajax" in search. There is a lot of material here on the site about AJAX.
– Sam
This does not need to be done in AJAX, the click on the button you can do in JS just with the click action gets true, clicked gets false and change the value of the text on the button, this will not generate page reload, if that is the problem.
– Eduardo