Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Clear all items that was selected from dropdown list

Avatar

Level 2

I have dropdown box with list of predifined items, from which I can select items into a text field with an add and remove buttons. these all work very nice.

Currently I have to remove one by one item incase I made some wrong selections via the remove button. You need to select the item and then click remove to have the item remove.

the section under the remove button is as below and work 100%

 

form1.ListSAPApplication.deleteItem(form1.ListSAPApplication.SelectedIndex);

I would now like to add another button to "clear all" selections from the text field without the necessity to first select the item. When I click CLEAR ALL button all of the selections should be cleared..

any idea how to write the statement to clear ALL selections from text box.

Thank you kindly.

7 Replies

Avatar

Not applicable

There are a lot of examples for reset button in this forum.  Can you use resetData() which clears all the fields in the form?

Avatar

Level 2

Thanks Niall

I already have a reset button added to my form to clear everything completely and do use the following script

 

<

script contentType="application/x-javascript">xfa.host.resetData();</script

>

The "reset" button do clear all normal data fields but even the RESET button do not clear the data entered into a text field from a drop down selection.

untitled.JPG

I can delete one item at a time by selecting the value and then click remove.

I want to add another button that say "Remove All" and then all the values selected must be removed from this text field.

the current script for "Remove" button is.

 

I just want to change the above code that I can add to my REMOVE ALL button, to delete ALL items and not only the selected one.

 

I am new to adobe forms forum. how do you upload a form so that you can see?

Regards

JB

<

contentType="application/x-javascriptscript

 

">

form1.ListSAPApplication.deleteItem(form1.ListSAPApplication.selectedIndex);</script>

 

Avatar

Level 10

Hi,

The resetData() will clear all data. The example above is intended to show how you can target specific fields.

However you want to remove specific sections within the textfield, which will require the replace() method. This is where you look for a match in the textfield's .rawValue and replace it with an empty string "".

You can't upload files directly to the forums, but if you put it in a file sharing site and post the published link here I will have a look at it when I can.

Niall

Avatar

Level 2

Thank you Niall

let me find a site where I can upload the form. any recommendations for sites you normally use.

In the mean time I will spend some more time on this and see where I am missing the plot..

Much appreciated

Avatar

Level 10

Hi,

I would recommend Acrobat.com, but please bear in mind that you need to Publish the file before it is available to anyone else.

Have a look at this example I did up for someone else. https://acrobat.com/#d=6hEiR5CSyQe1yUiqWXwEbg. Here it is looking at the rawValue of the listbox and stripping out the newlines (\n).

It might help,

Niall

Avatar

Level 2

Niall

after some more investigating I found something that will clear this.

 

form1.ListSAPApplication.clearItems();

Never thought about a "clear", was struggling with reset etc..

Thank you so much for your help.