Three inputs within the same form. Can I do your actions without leaving the page (without refresh)?

0

Blz Galera. I have three buttons inside the same form (register, change and view) and would like to do the actions of the buttons without leaving the page. How can I do this? Some colleagues commented on Ajax. Is there any example?

In case the form looks like this:

<form id="locadora" name="locadora method="post">

<input type="text" name="txt_titulo" size="38" maxlength="30" style="border-radius: 5px;"/>

<select id="txt_categoria" name="txt_categoria" style="border-radius: 4px;">
<option value="Séries">Séries</option>
<option value="Animes">Animes</option>
<option value="Filmes">Filmes</option>
</select>

<select id="txt_audio" name="txt_audio" style="border-radius: 4px;">
<option value="Dublado e Legendado">Dublado e Legendado</option>
<option value="Dublado">Dublado</option>
<option value="Legendado">Legendado</option>
</select>

<input name="visualizar" type="submit" id="visualizar" value="Visualizar"/>
<input name="alterar" type="submit" id="alterar" value="Alterar"/>
<input name="cadastrar" type="submit" id="cadastrar" value="Cadastrar"/>

Thank you

    
asked by anonymous 26.01.2018 / 23:50

1 answer

0

Speak Marcio! Look, there are several ways to do this. I believe that the ideal and most used is to use JavaScript to manage these button events. Here's an example below:

<!DOCTYPE html>
<html>
<body>

<p>Click "Try it" to execute the displayDate() function.</p>

<button id="myBtn">Try it</button>

<p id="demo"></p>

<script>
document.getElementById("myBtn").onclick = displayDate;

function displayDate() {
    document.getElementById("demo").innerHTML = Date();
}
</script>

</body>
</html> 

If you need some more examples. Follow the W3S reference link: link

    
27.01.2018 / 01:31