In a shopping list, write a name and view each item purchased by that name

How to load data from a list by writing the element in a textbox.

I would like to make a shopping list organized in this way

First name:

Angel

Purchased item:

Bread

pasta

fruit

===

First name:

Paul

Purchased item:

candies

ice creams

tomatoes

===

First name:

Andrew

Purchased item:

Beans

Peas

Cheese

I would like to use a "Search" button and a "textbox1", where by entering the name, for example: Paolo, in textbox1 and clicking on the search button, the objects purchased by Paolo are displayed, in this case on three textboxes:

Textbox1 = Paul

textbox2 = Candy

Textbox3 = Ice creams

texbox4 = Tomatoes

How can I do?

you can do it with a list containing the name and another list of lists, each sublist contains the purchased items for each name
to search for the name, just use the index in list block together with the name list to get the index, in the example 2
then use the select list item block together with that index to get the purchased items from the list of lists

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

You don't want to know

  • when they went shopping?
  • how many of each they bought?
  • how much they paid?

P.S. You can store shopping lists in TinyDB, with
tag = name (Paul, Andrew,...) and
value = shopping list (if not found, create empty list)

Load a List Picker of shopper names with the TinyDB TagList, and when a shopper is selected, load his shopping list into another List Picker, or display it in a Label using JOIN With Separator '\n' to look nice.

You don't need lots of text boxes for this.

1 Like

Thanks for all and you two are really kind, but in this way I do not understand anything I have downloaded the file aia but I can not follow every block, I apologize but unfortunately I am not able. You can, if I do not bother you, complete this .aia file that I am sending you and that you see in the picture.

Once I insert the data in the three textboxes and save them, when I then want to load the ones I need among the dozens of data that I need by writing only the name in the search txbox.
Then as soon as you click on search in the top three texboxes, the data associated with that name must appear.
I have inserted three Lists as suggested below but if one was even better.

.

Here is a sample using Namespaces to keep a price list and a shopping list with quantities.

You would need to extend it with one NameSpace per shopper, to store their separate shopping lists.

Here's a simple example so you can see how this can be done:

Blocks

Mi scuso forse sono io che non riesco a spiegarmi bene ilrpoblema da risolvere e spesso anche quando mi date le risposte esatte fatica a comprendere .
Mi pare però che la tua soluzione sia ottima, ma per selezionare con il dito il nome come nell'esempio e riportando l'elenco dei prodotti nella lista sono in grado di farlo.
IO non devo selezionare con un dito il nome, ma voglio procedere in questo modo:
Scrivo il nome(Peter" nella texbox di ricerca
Premo sul pulsante search che effettua la ricerca e trovato il nome dovrebbe riportarmi,
Il nome in textbox1 che vedi in alto e i rpodotti che lui ha quindi acquisito:
IL prodotto 1 nella seconda texbox
Il prodotto 2 nella terza texbox

Meanwhile, I thank everyone for the effort you make to help me.
Here is another example where it seemed to me that I was able to solve the problem.

If you can look at the photos they will make you look better and then download the file aia to see where I am wrong.

I solved it like this:
I entered the names in the properties in "ElementsFromString"
Angelo, Mario, Giovanni
Then
I write the name to look for in texbox1, with the select button I look for the index number, corresponding to the name I write in textbox1, the number is shown in label 2
With the second button I read the index number of label2 and find the name, returning it to label1
Only this example doesn't work and I don't know why.

Lista_Elementi.aia (1.9 KB)

Your blocks would be more interesting than the screenshots.

I sent you the file to download, I thought it was enough. I send you the image of the blocks

How should that work?

I solved it like this:
I entered the names in the properties in "ElementsFromString"
Angelo, Mario, Giovanni
Then
I write the name to look for in texbox1, with the select button I look for the index number, corresponding to the name I write in textbox1, the number is shown in label 2
With the second button I read the index number of label2 and find the name, returning it to label1
Only this example doesn't work and I don't know why.

grafik

I hope this time to be able to explain better

  1. I write "Mario" in the "textbox1"

  2. Click on the button "Label1 Position in the list: Mario" the result of him should be "2" reported in "Label1" exactly the place occupied in the list as you can see Mario is in place n ° 2.

  3. Click on the "Label2 Index_Name" button which reads the number "2" in the "label1", looks for the list and finds that position no. 2 corresponds to the name "Mario", extracts it and writes it in the " label2. Position = 2 - 2 = Mario "

That way it should work but it doesn't work.
A friend told me it doesn't work, because I didn't enter the names one by one with a (Create List) button.
Instead I populated the list with the ready-made names by inserting them as elements in the property: ElementsFromString
But if I did it this way, inserting one name at a time in the list, if the names were 500, it would take an exaggerated time to insert them all.
So I have to put them in the property: “ElementsFromString“ of the list. At the top right of the space concerned, as you can see in the image, I have to find a way to search the list automatically and report the name, in a space I prefer, in this case the label2.

Maybe having entered the names all together I don't have to create the "List" variable)

There is no point in asking the same question a third time.

I recommend that you first learn some basics (including basics about lists and lists of lists). And then take a closer look at my blocks.
Btw, debug your blocks ... (right mouse click → Do it).

Thank you very much, you have been very kind, I will follow the advice.
But right click in which part of appinventor should I do it?
Where are your blocks?

grafik

See also here (→ point 4):