Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I get this error, when trying to remove onclick so it wont create double element on every button click.

It works when clicking on the button many times but after a wild i get this error:

VB
Line: 2
Error: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.


here is my code

JavaScript
$(function () {$("#dialog").dialog({
           autoOpen: false

   });


       var node = document.createTextNode("Lediga tider att boka");
       var para = document.createElement("p");
       var selectList = document.createElement("select");

       var element = document.getElementById("textresultfree");
       while (element.hasChildNodes()) {
           element.removeChild(element.firstChild);
       }
       var myDiv = document.getElementById("myDivResult");
       while (myDiv.hasChildNodes()) {
           myDiv.removeChild(myDiv.firstChild);
       }
       para.appendChild(node);
       element.appendChild(para);
       myDiv.appendChild(selectList);


           $("#dialog").dialog("open");
           var free = "";
           for (var j = 0; j < bookedFreeTimes.length; j++) {

               free = bookedFreeTimes[j];
               var array = new Array(free);

               for (var k = 0; k < array.length; k++) {

                   var option = document.createElement("option");
                   option.text = array[k];
                   selectList.appendChild(option);

               }
           }

           }

       );
   }
Posted
Comments
Afzaal Ahmad Zeeshan 5-Dec-14 10:10am    
I am not able to find the bookeFreeTimes, where actually is it? I think that is the problem.

Or you need to add a few elements to the array (Array) variable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900