JS Function Stops Executing

Hi Experts,

I have the following function, but for some reason the for loop stops executing mid way. For example, I get my "OK", I get my "OK2", but I never get my "id = ...".  As well,  I know I have a return false mid way, but that should not prevent my third alert from showing.
function checkRequired(){
    var letter = '';
    var id = -1;
    var veh = 0;
    var arch = false;
    for(i = 1; i < 7; i++){
        letter = number_to_letter(i);
        id = document.getElementById('txtTrip[' + letter + ']').value.parseInt();
        veh = document.getElementById('cboVehicle[' + letter + ']').value;
        arch = document.getElementById('chkArchived[' + letter + ']').checked;
        alert('id =' + id + ' veh =' + veh + ' arch =' + arch);
        return false;
        if ((id > -1) && (veh === '0,0') && (arch === false)){
            alert('The vehicle for all open and non-cancelled trips is mandatory.');
            return false;
    return true;

Open in new window

APD TorontoSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ronak PatelCommented:
Hi APD_Toronto,

It probably be failing on id = document.getElementById('txtTrip[' + letter + ']').value.parseInt(); line.

Please put an alert(letter); after letter = number_to_letter(i); line and check what value you are getting in the letter variable.

If letter variable has valid value then check document.getElementById('txtTrip[' + letter + ']') element is available on the page or not.
If its not available, it won't execute further.

To know what error you are getting, run your page in internet explorer and press F12 and check Console to get exact error detail.

Hope this helps.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey Dake Senior Director of TechnologyCommented:
Have you tried looking in the console of your browser for errors.   If you are using chrome you can right click in the window and inspect an element on the page. Once the development tools window pops up you can look at the console tab to see if any errors are occurring. My guess is your parseInt has some error which is stopping the rest of the function from running.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.