PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] Why can not I get the input of these fields? JavaScript

 July 13, 2022     backend, forms, function, javascript, web-deployment     No comments   

Issue

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.


Solution

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;
};


Answered By - Mustard Shaper
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing