1
Hello, I wonder how I can pass the value of a field that is in (index.html) to a function that is (data-user.js).
I have an application in nodejs using Electron, the main calls index.html, which mounts the screen, and has some fields, NAME, EMAIL and a button. When I press the button I want to send the value of the fields to a function that is in a class (.js).
<form method="post" action="">
<h1>Ativar Notificações</h1>
<p>
<label for="nome_cad">Seu nome</label>
<input id="nome_cad" name="nome_cad" required="required" type="text" placeholder="nome" />
</p>
<p>
<label for="email_cad">Seu e-mail</label>
<input id="email_cad" name="email_cad" required="required" type="email" placeholder="[email protected]"/>
</p>
<p>
<button onclick="sendData()" > Ativar </button>
</p>
</form>
I’m trying to do it this way, but it didn’t work:
<script type="text/javascript">
function sendData(){
const dataUser = require('./data-user');
dataUser(document.getElementById('nome_cad').value, document.getElementById('email_cad').value);
}
</script>
The data-user class is thus:
module.exports = async (nome, email) => {
console.log(nome);
console.log(email);
}
Thank you.