var message1, message2; document.forms.my.onsubmit = function() { message1 = this.one.value; message2 = this.two.value; console.log(message1+message2); return false; };