[Solved] What’s wrong in this JavaScript code?


I have to agree with comments above, not sure what you’re doing but…the problem is that a submit handler is a function not the string you’re assigning, this:

subBut.onclick = (document.getElementById('helllo').innerHTML=(submi(document.getElementById('user').value, document.getElementById('passw').value)));

should be:

subBut.onclick = function() { 
  document.getElementById('helllo').innerHTML=
    submi(document.getElementById('user').value, document.getElementById('passw').value);
  return false; //for testing, prevent form submission
}; 

You can test the updated version here.

1

solved What’s wrong in this JavaScript code?