From 034fe6688cbdc6970bee157d505c1677c15cee2c Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Thu, 11 Jul 2019 13:05:04 +0200 Subject: [PATCH] Updated 030 How to filter a list field based on association with another field (markdown) --- ...lter-a-list-field-based-on-association-with-another-field.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/030-How-to-filter-a-list-field-based-on-association-with-another-field.md b/030-How-to-filter-a-list-field-based-on-association-with-another-field.md index 00d18bf..6d1d082 100644 --- a/030-How-to-filter-a-list-field-based-on-association-with-another-field.md +++ b/030-How-to-filter-a-list-field-based-on-association-with-another-field.md @@ -35,7 +35,7 @@ SetRegion is quite simple, mainly because most of the work had already been done * ### Strings - Select_A_Region, Create_A_Region -[00:09:55](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m55s)The 'select_a_region' is a JavaScript variable that gets set through PHP, which will be discussed at later stage. Basically it's just a string that says that the region should be selected. [00:10:21](https://www.youtube.com/watch? v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m21s) If there is no array returned, other variable should be used, the 'create_a_region' which is also just a string. +[00:09:55](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m55s)The 'select_a_region' is a JavaScript variable that gets set through PHP, which will be discussed at later stage. Basically it's just a string that says that the region should be selected. [00:10:21](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m21s) If there is no array returned, other variable should be used, the 'create_a_region' which is also just a string. Go to 'jQuery.each(array,function(i,id){' , select 'array' and use the 'id', and check if the 'id' is in 'regions'. If it is in 'regions', append the 'id' as a value. As you remember in 'regions' the text as well as the 'id' had been saved. [00:10:51](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m51s) So that is how to get the text, simply adding it in there(see video). It could have been done in the PHP, but I felt let the browser help us with some of the lifting. There is regions, if it's a huge table it should be approached differently. Eventually it is checked whether the 'id' and the 'region' equals(id==region). Since if it does it is necessary to ensure to set the 'region' value.