-3

I have created a contact Form and I try to get the data of the name, email and message inputs trough a function when I trigger the Send Message button but the data do not print them out, are null, why?.

This is the name Field, the name class into the input enter image description here

This is the email Field, the email class into the input

enter image description here

This is the Message Field, the class message into the text area.

enter image description here

This is the function that triggers

enter image description here

This are the fields

enter image description here

And I get this when I trigger the function through the Sens Message Button.

enter image description here

Why do not store the data and print them out? Thank for you help guys.

5
  • Please don't post text content as images. Commented May 14, 2021 at 7:37
  • "DO NOT post images of code, data, error messages, etc. - copy or type the text into the question." - stackoverflow.com/help/how-to-ask Commented May 14, 2021 at 7:38
  • You haven't added either and id or name attribute. It's a good idea to use the id rather than a class name for specific form elements as id's should be unique within the document but class names are designed not to be. Commented May 14, 2021 at 7:40
  • 4
    For inputs you should use value not nodeValue. Commented May 14, 2021 at 7:41
  • SORRY GUYS FOR THE IMAGES, WILL NOR DO THAT AGAIN. Thanks @phuzi, that was the problem. Commented May 14, 2021 at 8:06

1 Answer 1

0

In your trigger() function, you should change .nodeValue to .value, so you get:

function trigger() {
    let name = document.querySelector('.name').value;
    let email = document.querySelector('.email').value;
    let message = document.querySelector('.message').value;
};
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.