Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2007, 03:21 PM   PM User | #1
justincredible
New Coder

 
Join Date: Jul 2006
Location: Cincinnati, OH
Posts: 85
Thanks: 1
Thanked 0 Times in 0 Posts
justincredible is an unknown quantity at this point
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..
justincredible is offline   Reply With Quote
Old 02-21-2007, 06:33 PM   PM User | #2
justincredible
New Coder

 
Join Date: Jul 2006
Location: Cincinnati, OH
Posts: 85
Thanks: 1
Thanked 0 Times in 0 Posts
justincredible is an unknown quantity at this point
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..
justincredible is offline   Reply With Quote
Old 02-21-2007, 10:48 PM   PM User | #3
justincredible
New Coder

 
Join Date: Jul 2006
Location: Cincinnati, OH
Posts: 85
Thanks: 1
Thanked 0 Times in 0 Posts
justincredible is an unknown quantity at this point
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.
justincredible is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:09 PM.


Advertisement
Log in to turn off these ads.