2

Adding "use strict" to this function is breaking it. Specifically the inputs I am trying to un-disable are remaining disabled in strict mode. csc_popup_in() and csc_popup_out() functions are defined prior to this one. Thanks in advance for any input.

function show_cc(){
    document.getElementById('cc_fade').className='none';

    var cc_inps = document.getElementById('cc_fade').getElementsByTagName('input');
    for(i=0 ; i<cc_inps.length ; i++){
        cc_inps[i].disabled=false;
    }

    document.getElementById('csclnk').onmouseover = function(){csc_popup_in();};
    document.getElementById('csclnk').onmouseout = function(){csc_popup_out();};

    if(document.getElementById('amex').checked){
        document.getElementById('cc_num').maxLength = 15;
        document.getElementById('cc_csc').maxLength = 4;
    } else {
        document.getElementById('cc_num').maxLength = 16;
        document.getElementById('cc_csc').maxLength = 3;
    }
}
4
  • 1
    Surely there's an error reported in your JavaScript console ... Commented Apr 30, 2013 at 0:07
  • As Pointy suggested, you should be looking for errors. Part of the benefit of strict mode is that you'll potentially get more errors telling you something's wrong in your code. This is a good thing. Commented Apr 30, 2013 at 0:23
  • 1
    Also, but you have unnecessary anonymous functions. You can directly assign the functions as handlers. For example: document.getElementById('csclnk').onmouseover = csc_popup_in; Commented Apr 30, 2013 at 0:24
  • +1 for the advice on handlers, thank you! Commented Apr 30, 2013 at 1:03

1 Answer 1

4

You forgot to declare "i" with var!!!

Sign up to request clarification or add additional context in comments.

1 Comment

Knew it was something stupid. I am self-taught so my debugging methods are not the best. I will work on getting better with JS console as suggested. THANKS!

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.