Hello All,
First off, I really appreciate the knowledge that many of the gurus on this forum share with us.
Secondly, I was hoping to get some ideas on how I can go about scripting for the following situation:
I have a checkbox that, when clicked, adds a new text item to a listbox in a separate subform. For this purpose, I use listbox1.additem(textField1).
I next create a few more checkboxes that add new text items to the same listbox.
Here is the heirarchy
form1
Main
subForm1
checkBoxA
textField1
subForm2
checkBoxB
textField2
subForm3
checkBoxC
textField3
subForm4
listBox1
The problem comes when I wish to remove the specific texts added to the listbox. For example, If I have CheckboxA, CheckboxB, and CheckboxC all checked, the listbox contains the following items:
TextbyCheckboxA
TextbyCheckboxB
TextbyCheckboxC
For example, this is the script I have for adding and removing "TextbyCheckboxB" from the listbox. The script is in the change event of the checkBoxB object in subForm2:
if (this.rawValue == 1)
Main.subForm4.listBox1.addItem(subForm2.textField2.rawValue);
else
var strTemp = subForm4.listbox1.getDisplayItem(i)
for (i=0; i<subForm4.listBox1.length; i++){
if (strTemp = subForm2.textField2.rawValue)
subForm4.listBox1.deleteItem(i);
}
...this script keeps removing only the first item in the listbox, regardless of what order the texts are put into the listbox. It appears that this looping script should only be deleting the items where the display item matches the text in the textfield, which is precisely what I'm trying to do.
Where am I going wrong here?
Thanks again for any help. I've been trying to figure this out for 3 days now.
Solved! Go to Solution.
Views
Replies
Total Likes
You can do this in the following way:
for (var i = 0; i < listBox1.items.nodes.length; i++) {
if (listBox1.items.nodes.item(i).value === subForm2.textField2.rawValue) {
listBox1.deleteItem(i);
}
}
Views
Replies
Total Likes
You can do this in the following way:
for (var i = 0; i < listBox1.items.nodes.length; i++) {
if (listBox1.items.nodes.item(i).value === subForm2.textField2.rawValue) {
listBox1.deleteItem(i);
}
}
Views
Replies
Total Likes
Wow radzmar!!!!
I have no idea how you knew to do this, but you are guru, indeed!
This works PERFECTLY!
Yay!!!!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies