Cage Cage - 1 year ago 36
Javascript Question

print or show current value of variable in console.log

With the below; I am attempting to capture form field contents on click of submit button. However when I go to test it and console.log the variable I just get the HTML of the form field. Any pointers. Or I get uncaught reference error, the variable is not defined.

Mark-Up wise: I'm using input type text and input type radios.



var firstName01 = document.getElementById('firstName').value;

var firstName02 = document.getElementById('firstName2').value;

var lastName01 = document.getElementById('lastName').value;
var lastName02 = document.getElementById('lastName2').value;

var iphone01 = document.getElementById('iphone').value;
var android01 = document.getElementById('android').value;

var iphone02 = document.getElementById('iphone2').value;
var android02 = document.getElementById('android2').value;


Answer Source

Try using .textContent instead of .value

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download