Copy link to clipboard
Copied
Greetings everyone!
After a few months of pausing in my studies, I decided to return and soon I ran into an error in the script I picked up on this one on page 31 of this manual: https://adobeindd.com/view/publications/a0207571-ff5b-4bbf-a540-07079bd21d75/92ra/publication-web-r...
My question is: How to return only the items in the text box after deleting some? It prints all items even after deleting. Where's the error?
Thank you
var w = new Window ("dialog");
var array= ["one", "two", "three", "four"]
var lbx = w.add ("listbox", undefined, array, {multiselect: true});
var del = w.add ("button", undefined, "Delete selected items");
del.onClick = function () {
// remember which line is selected
var sel = lbx.selection[0].index;
for (var i = lbx.selection.length-1; i > -1; i--)
lbx.remove (lbx.selection[i]);
// select a line after deleting one or more items
if (sel > lbx.items.length-1)
lbx.selection = lbx.items.length-1;
else
lbx.selection = sel;
}
var print = w.add ("button", undefined, "Print selected items");
print.onClick = function () {
for (var i = 0; i < array.length; i++)
alert(array[i]);
}
w.show ();
var print = w.add ("button", undefined, "Print selected items"); // why selected???
print.onClick = function () {
for (var i = 0; i < lbx.items.length; i++)
alert(lbx.items[i].text);
}
Copy link to clipboard
Copied
var print = w.add ("button", undefined, "Print selected items"); // why selected???
print.onClick = function () {
for (var i = 0; i < lbx.items.length; i++)
alert(lbx.items[i].text);
}
Copy link to clipboard
Copied
Great, it worked now! Thank you r-bin , I am happy to know that you still attend this community.
Copy link to clipboard
Copied
How are items removed from an array. I've tried so many things but it simply won't work.
Why I test typeof(arrayName), it returns an object even though declared as array. I believe estk tells an array to be an object.
But I can get it to work to remove an item of that array.