Home > Blockchain >  Add JS Form Action
Add JS Form Action

Time:09-30

I'm creating an HTML form but I don't know much about JS, and I need help.

When the user fills in and clicks on the button, I would like a text to appear and in the middle of the text I could pull the values ​​that he put in the form.

Example:

Name: Luis Email: [email protected]

Text after clicking send: Hello Luis. His email is: [email protected]

Do you know how I can do this action? My HTML form is this:

<label  for="name">Nome do Código</label>
<input  type="text" placeholder="Digite o nome do código..." />
<label  for="name">Linguagem</label>
<select >
    <option value="code">CSS</option>
    <option value="code">JS</option>
    <option value="code">PHP</option>
    </select>
<label  for="name">Como usar?</label>
<input  type="text" placeholder="Explique como o código será usado..." />
<label  for="name">Código</label>
<textarea  placeholder="Cole o código aqui." /></textarea>
<button  type="submit">Enviar sua mensagem</button>

CodePudding user response:

I would add the name tag to your inputs and do something like this

//app.js
app.post("/someForm", (req, res) => {
  const { email, name } = req.body;

  res.render("welcomeUser", { name: name, email: email });
})
<!-- welcomeUser.ejs -->

<h4>Hello <%= name %>. His email is: <%= email %></h4>

There might be a better answer but this was the one that was coming to my mind

  • Related