www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Problem With Undefined Array Items

Hybrid View

  1. #1
    Join Date
    May 2011
    Posts
    2

    resolved [RESOLVED] Problem With Undefined Array Items

    I've been trying to solve this in the past few days without success, the problem I have is that I have 3 pairs of arrays, the first pair works all well but the other two pairs, come as undefined.

    What I'm trying to achieve is dynamically created dropdows with the second and third dropdowns dependent of the first one, where this two are filled depending of whats selected in the first box.

    Code:
                                                                        /////////////////////
                                                                        // Array Variables //
                                                                        /////////////////////
    
    //This ones works well
    var arrInput = new Array(0);
    var arrInputValue = new Array(0);
    
    //The 1st is only undefined, the second have values when the boxes are selected
    var arrInputConditions = new Array(0);
    var arrInputConditionsValue = new Array(0);
    
    //same as last one
    var arrInputValues = new Array(0);
    var arrInputValuesValue = new Array(0);
    
    var strStyle = "width=100%";
    
                                                                        /////////////////////////
                                                                        // Add Inputs Function //
                                                                        /////////////////////////
    
    function addInput() 
    {
        arrInput.push(arrInput.length);
        //arrInput.push(createInput(arrInput.length));
        arrInputValue.push(arrInputValue.length);
        //arrInputValue.push("");
        
        arrInputConditions.push(arrInputConditions.lenght);
        //arrInputConditions(createInputConditions(arrInputConditions.lenght));
        arrInputConditionsValue.push(arrInputConditionsValue.lenght);
        //arrInputConditionsValue.push("");
        
        arrInputValues.push(arrInputValues.lenght);
        //arrInputValues(createInputValues(arrInputValues.lenght));
        arrInputValuesValue.push(arrInputValuesValue.lenght);
        //arrInputValuesValue.push("");
        
        display();
        displayConditions();
        displayValues();
    }
    
                                                                        ///////////////////////
                                                                        // Display Functions //
                                                                        ///////////////////////
    
    function display() 
    {
        document.getElementById('fields').innerHTML="";
        
        for (intI=0; intI < arrInput.length; intI++) 
        {
            document.getElementById('fields').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
        }
    }
    
    function displayConditions() 
    {
        document.getElementById('conditions').innerHTML="";
        
        for (intIC=0; intIC < arrInput.length; intIC++) 
        {
            document.getElementById('conditions').innerHTML+=createInputConditions(arrInput[intIC], arrInputValue[intIC]);
        }
    }
    
    function displayValues() 
    {
        document.getElementById('values').innerHTML="";
        
        for (intIV=0; intIV < arrInput.length; intIV++) 
        {
            document.getElementById('values').innerHTML+=createInputValues(arrInput[intIV], arrInputValue[intIV]);
        }
    }
    If you need more code to understand the problem, just ask for it, but I think the problem must be along those lines.

  2. #2
    Join Date
    Mar 2011
    Posts
    61
    You've misspelled length in a couple of places.

  3. #3
    Join Date
    May 2011
    Posts
    2
    OMG. Can't believe it, so much time wasted and didn't noticed that...

    Well thanks so much for pointing that out, I'm so dependent on debugger stuff, in .net compilers that would tell me right away about the typo.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles