1

I have read this article Need helping with innerHTML and array input variables. But when i do this:

 if (errors.length > 0) {
    var htmlErrors ='';
    for (var i = 0; i < errors.length; i++) {    
        htmlErrors += errors[i];
    }
    document.getElementById("registration_errors").innerHtml = htmlErrors;

I get white screen. Where is my mistake?

4
  • Do you have any console error in your browser? Commented Sep 24, 2014 at 8:26
  • try adding console.log(errors) before if to see the content of errors. Commented Sep 24, 2014 at 8:27
  • 1
    innerHTML, not innerHtml Commented Sep 24, 2014 at 8:28
  • thats help thanks a lot.i need be more attentive) Commented Sep 24, 2014 at 8:40

2 Answers 2

3

Try: innerHTML Link

document.getElementById("registration_errors").innerHTML = htmlErrors;
Sign up to request clarification or add additional context in comments.

Comments

1

The if is not closed and this is innerHTML instead of innerHtml:

if (errors.length > 0) {
    var htmlErrors ='';
    for (var i = 0; i < errors.length; i++) {    
        htmlErrors += errors[i];
    }
    document.getElementById("registration_errors").innerHTML = htmlErrors;
}

2 Comments

if closed, i just not add the end quote) sorry)
Without the whole context, I have nothing else to say … errors exists and it's an no-empty array of string ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.