I would like to have a button that clears the selection of a bunch of list boxes. I have tried using the following JS which works well for reseting Radio Bottons:
What is the equivalent Button JS code for clearing the selection of a list box?
Use 'clearItems()' to do that.
Sorry, I should have explained this better. What I was hoping to achieve is not clear the choices in the List Box that are being offered but the one that is selected. By default, one is chosen as being selected. I was wondering if it were possible to clear that selected default. So that it is a clean list. I would have put in a blank (no script) choice in the list but that cannot be done.
I'm not sure what you want. You say you want to delete selected item in a List Box
var f = this.getField("List Box1");
you can use it in a button.
But you also say you want 'clean list'. what does that mean?
Why can't you put blank? you can add it as any other value, press 'space' when adding values.
This code should do it... It will revert those fields to their default selections.
What happens when you use it?
It clears the list entirely
I was referring to the code you posted, not the one from Nesa.
One additional question, regarding the usual way that List Box selections work. Currently, under the Options Tab within the List Box Properties there is a check box for Multiple selection. When I multi-select the items and merge them to another Text Field they are comma separated but without a space between the comma and the next script (ie 1,2,3 rather than 1, 2, 3). Is there a way I can create the latter? I was wondering if placing appropriate JS within the Selection Change tab might offer a solution. I am aware that placing a space before the listed item offers a solution however this assumes that more than one item is being selected which in some cases it isn't.
How does you merge the items?
Within the merging Text Field JS I place:
event.value = this.getField("ListBox1").value
This also has the Multi-line check box selected within the Options tab.
ListBox1 is a list of items with the check box for Multiple selection checked within the Options tab.
Use this code:
var v = this.getField("ListBox1").value;
if (typeof v=="string") event.value = v;
else event.value = v.join(", ");
Works very nice, thank you TRY67.
In the properties of the list box don't select any list item.
And use resetForm.
Sorry, for my ignorance. I didn't realise that I could deselect the list box item from being a default choice by mouse clicking below the list choices in the Properties\Options tab. Then I used the button with the below JS and it worked perfectly.
Actually, I also discovered that if I used:
the button selection cleared all the Group1 List Boxes.