I need help doing exact matches on a string. I think my string.replace is removing more than it should, sometimes. All the values i am storing in an array are numbers, i think thats the issue maybe.
I have two listboxes, and code to move the items from the first one over to the second one. I am recording the second one as the selected options.
I am storing the selected options in a textbox. Now when someone REMOVES an item, it updates the textbox removing the value that was removed.
Once the form is submitted, i will be using the textbox value in a string split on the semicolon.
Overall its working ok one by one, and many multiples, but there is a situation when all is selected, then removed, it leaves some partials.
heres the results from a select all (or adding all one by one)
here's the remaining results from remove all
Notice, that 89 is not even in the above list!
Thanks for any insight you can provide.
I have two listboxes, and code to move the items from the first one over to the second one. I am recording the second one as the selected options.
I am storing the selected options in a textbox. Now when someone REMOVES an item, it updates the textbox removing the value that was removed.
Code:
for (var i = 0; i < from.options.length; i++) {
var o = from.options[i];
if (o.selected) {
if (!hasOptions(to)) { var index = 0; } else { var index = to.options.length; }
to.options[index] = new Option(o.text, o.value, false, false);
[b]listing.value = checkOptionSavedValues(listing.value, o.value);[/b]
}
}
function checkOptionSavedValues(curVal, newVal) {
if (curVal.match(newVal)) {
curVal = curVal.replace(newVal, "");
}
else {
curVal += newVal + ";";
}
return curVal.replace(";;", ";");
}
Once the form is submitted, i will be using the textbox value in a string split on the semicolon.
Overall its working ok one by one, and many multiples, but there is a situation when all is selected, then removed, it leaves some partials.
heres the results from a select all (or adding all one by one)
Code:
16;57;17;8;79;4;77;11;95;18;19;76;83;40;75;23;22;87;62;90;74;91;26;60;39;92;28;70;73;44;88;30;31;12;33;34;81;35;59;78;86;13;
here's the remaining results from remove all
Code:
;8;0;89;90;
Thanks for any insight you can provide.