Conditional calculation for popup menu?

Viewing 6 reply threads
  • Author
    Posts
  • May 24, 2018 at 12:26 PM #28744

    Barry Levine
    Participant

    I 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, Rachel

    So, 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,
    Barry

    May 24, 2018 at 3:01 PM #28745

    Brendan
    Keymaster

    Hi 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 Levine
    Participant

    Thanks for the reply.

    Is there an “If/Then/Else” structure of some kind?

    Barry

    May 24, 2018 at 9:57 PM #28750

    Brendan
    Keymaster

    Hi 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 Levine
    Participant

    Too 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

    Brendan
    Keymaster

    The 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

    Brendan
    Keymaster

    Here’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 Hayes
    Participant

    The 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.

Viewing 6 reply threads

You must be logged in to reply to this topic.