Results 1 to 2 of 2

Thread: Quick Question...code loads Select twice?

  1. #1
    Join Date
    Jul 2013
    Posts
    41
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Quick Question...code loads Select twice?

    Greetings, Jan 1st 2013

    A brief question, why would the below code load the information twice while it appears to have looped twice. Works great just loads the select box with the same variables twice? The commented line as well works great alone, however, double loads ..any ideas?

    Appreciatively,
    Ted

    Code:
    for(i = 0; i < 11; i++){
    	val='test line - '+i;
    	txt='test'+i;
    	//document.getElementById("companyspecificmacs").add(new Option(testtxt,testtxt));
        var x = document.getElementById("companyspecificmacs");
        var option = document.createElement("option");
            option.text = 'test line - '+i;
         try {
             x.add(option, x.options[null]);
             }
               catch (e) {
               x.add(option, null);
                         }
    
    	                    }
    Last edited by keyboard; 01-04-2014 at 01:34 AM. Reason: Format: Code Tags [code][/code]

  2. #2
    Join Date
    Jul 2013
    Posts
    41
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    In further discussing the above situation, I have found that an elements state which alters as I devised will call the populate Select box, hence, the routine will continually load each time to appear as multiple loops. the obvious fix, clear the select in the above routine.

Similar Threads

  1. Replies: 0
    Last Post: 05-24-2010, 06:01 PM
  2. Quick Question
    By Taz002 in forum Other
    Replies: 3
    Last Post: 08-18-2009, 11:03 PM
  3. Quick question about this snippet of code:
    By Jon101 in forum JavaScript
    Replies: 14
    Last Post: 11-13-2008, 09:29 PM
  4. Quick Css Question need Help
    By seattle-west in forum CSS
    Replies: 2
    Last Post: 07-26-2007, 11:21 PM
  5. Quick Question
    By Jon101 in forum Flash
    Replies: 10
    Last Post: 06-10-2007, 09:52 PM

Bookmarks

Posting Permissions

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