Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re-populating an empty multiselect...

    Code:
    function buildSelect(status){
         var xmlhttp=false;
         try{// Firefox, Opera 8.0+, Safari
              xmlHttp=new XMLHttpRequest();
         }
         catch (e){// Internet Explorer
              try{
                   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
              }
              catch (e){
                   try{
                        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (e){
                        alert('Your browser does not support AJAX!');
                        return false;
                   }
              }
         }
         var file = 'chapterAjax.php?chapterStatus=';
         xmlHttp.open('GET',file+status,true);
         xmlHttp.onreadystatechange=function(){
              if(xmlHttp.readyState==4){
                   for (x = document.getElementById('selectedChapter').length; x >= 0; x--) {
                        document.getElementById('selectedChapter')[x] = null;
                   }
                   var content = xmlHttp.responseText.split(",");
                   document.getElementById('selectedChapter')[0] = content[377];
                   for(var i=0;i<content.length;i++){
                        document.getElementById('selectedChapter')[i] = content[i];
                   }
                   document.getElementById('activeChapterBox').disabled = false;
                   document.getElementById('workingChapterBox').disabled = false;
                   document.getElementById('nonactiveChapterBox').disabled = false;
                   document.getElementById('hiddenChapterBox').disabled = false;
                   document.getElementById('modifiedChapterBox').disabled = false;
         }
         else{
              document.getElementById('activeChapterBox').disabled = true;
              document.getElementById('workingChapterBox').disabled = true;
              document.getElementById('nonactiveChapterBox').disabled = true;
              document.getElementById('hiddenChapterBox').disabled = true;
              document.getElementById('modifiedChapterBox').disabled = true;}
         }
         xmlHttp.send(null);
         return;
    }
    I cannot seem to get the bolded part to do the correct thing.

    The for-loop before that is used to completely wipe out my multiselect and I want the bolded code to re-populate that multiselect with the elements that are now in content.

    Any ideas?
    Last edited by justincredible; 02-21-2007 at 10:30 PM.

  • #2
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This is the error that I am getting in firebug which means absolutely nothing to me:

    [Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://myurl.com :: anonymous :: line 1035" data: no]
    Last edited by justincredible; 02-21-2007 at 10:32 PM.

  • #3
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    When I alert on content[i] it gives me the right thing so I know it is splitting it correctly.

    document.getElementById('selectedChapter')[i] is obviously wrong.

    I believe I tried document.getElementById('selectedChapter').option[i] as well but it didn't work either.


  •  

    Posting Permissions

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