Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Conditional calculation for popup menu?
Tagged: conditional, if then, pick list
- This topic has 7 replies, 3 voices, and was last updated 6 years, 5 months ago by James Hayes.
-
AuthorPosts
-
May 24, 2018 at 12:26 PM #28744
Barry LevineParticipantI did not see this in any of the tutorial videos (I might have missed it). Is there a way of telling tapforms to use a specific pick list in a form based upon the content of another field?
For example:
If field “Gender” contains “Male” then use (for the pick list) “Male Names”
-otherwise-
use (for the pick list) “Female Names”The pick list for “Male Names” contains Tom, Dick, Harry
The pick list for “Female Names” contains Sue, Mary, RachelSo, in each record in this table, the pick list that’s displayed for the user is dependent upon whether the field named “Gender” contains the word “Male” or “Female. Obviously, a “Gender” pick list containing “Male, Female” choices would be required in order to prevent an errant misspelling.
Thank you,
BarryMay 24, 2018 at 3:01 PM #28745
BrendanKeymasterHi Barry,
There’s no functionality for conditional Pick Lists. But it is something I’d like to add at some point.
Thanks,
Brendan
May 24, 2018 at 4:17 PM #28746
Barry LevineParticipantThanks for the reply.
Is there an “If/Then/Else” structure of some kind?
Barry
May 24, 2018 at 9:57 PM #28750
BrendanKeymasterHi Barry,
There is for the Calculation field type right now which provides a variety of conditional expressions. And I’m just adding a new Script field to let you do more advanced scripting in Tap Forms using JavaScript code.
May 24, 2018 at 11:32 PM #28754
Barry LevineParticipantToo bad it can’t be LiveCode’s scripting language (a superset of HyperCard’s HyperScript). Much easier to learn. :D
However, any scripting language is better than none at all, eh?
Thanks very much.
Barry
May 25, 2018 at 12:17 AM #28756
BrendanKeymasterThe benefit of using JavaScript was that it was built-in to macOS and iOS via Apple’s JavaScriptCore framework.
May 25, 2018 at 12:20 AM #28757
BrendanKeymasterHere’s an example of code which will fetch a JSON file over the Internet, parse it, and create records in Tap Forms based on the data in the file:
var countryID = 'fld-d8c773b094b64326872e648bede6611f'; var cityID = 'fld-4a1e0f83ed394e439fbdf5239a9329e2'; var timeZoneID = 'fld-089bde2a69674f928c8942644930288f'; function fetchCities() { var cities = Utils.getJSONFromURL('https://www.tapforms.com/CitiesAndTimeZones.json'); return cities; } var cities = fetchCities(); function addRecords() { for (var index = 0, count = cities.length; index < count; index++){ var newRecord = form.addRecord(); var country = cities[index]['country']; var city = cities[index]['name']; var timeZone = cities[index]['timeZoneName']; newRecord.setFieldValue(countryID, country); newRecord.setFieldValue(cityID, city); newRecord.setFieldValue(timeZoneID, timeZone); } return; } addRecords();
So it’s not too complicated :)
May 25, 2018 at 9:14 AM #28760
James HayesParticipantThe other benefit is JavaScript is a modern language where as LiveCode and HyperCard are specialized languages for which there is very little documentation and the chances of finding someone to help when you are stuck with code that does not work is zero.
-
AuthorPosts
You must be logged in to reply to this topic.