Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximum String Length

Status
Not open for further replies.

BB101

Programmer
May 23, 2001
337
GB
Im trying desperately to load data (6000-50000 records) into a select box, I have decided adding them in one at a time with new Option is just too slow so im compiling a large piece of HTML to use with outerHTML to re-render the entire select box at once. However, I seem to have a problem with my script and I can't see where. I am parsing a large string via a function parameter and trying to assemble the select box from there. However, im getting errors where I shouldn't be. Is there a maximum length to string variables in javascript? Is there an easy work around (using arrays perhaps)?

Thanks in advance

--BB
 

>> Is there a maximum length to string variables in javascript?

I'm not sure about this one - I've sucessfully had 64Kb in a string with no issues.

Are your problems possibly caused by something else - like unescaped apostrophes or quotes, for example?

Hope this helps,
Dan
 
Im using RPC code to load the stuff in dynamically (if you dont know wot it is move on to another article).

This is a heavily snipped verson of the code coming out of the RPC
Code:
loadMembers("8", "0", "<option value='269' SELECTED>296@email.address[!SNIP!]<option value='30401' SELECTED>30401@email.address")}
rpc_remove(1);

This is then picked up by the following code:
Code:
//group_html[group_id][email_id] = html;
var group_html = new Array();
function loadMembers(group_id, email_id, str) {
  if (!group_html[group_id]) group_html[group_id] = new Array();
  group_html[group_id][email_id] = str;
  displayMembers();
}

function displayMembers() {
  var obj = o("groupList");
  if (document.forms['mail'].loadedEmail.selectedIndex > 0) {
    var email_id = document.forms['mail'].loadedEmail.options[document.forms['mail'].loadedEmail.selectedIndex].value;
  } else {
    var email_id = 0;
  }
  
  var html = "<select name='member[]' id='memberList' size=10 multiple style='width: 200px;'>";
  for (var i=1; i<obj.options.length; i++) {
    if (obj.options[i].selected) {
      var group_id = obj.options[i].value;
      if (!group_html[group_id] || !group_html[group_id][email_id]) {
        rpc("getMembers.php", "group_id=" + group_id + (email_id == 0 ? "" : "&email_id=" + email_id));
      } else {
        html += group_html[group_id][email_id];
      }
    }
  }
  html += "</select>";
  o("memberList").outerHTML = html;
}

This makes an error on line 1 (nice and vauge). Anyone?

Thanks

--BB
 
one less } and a semi-colon later and all is working :)

--BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top