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

Asked

Viewed 19 times

0

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

In case the form is 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

1 answer

0

This is Marcio speaking! 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. Follow 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 a few more examples. Follow the W3S reference link: https://www.w3schools.com/js/js_htmldom_events.asp

Browser other questions tagged

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