Hiding fields based on checkbox

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
ben
Posts: 1
Joined: Mon Aug 06, 2018

06 Aug 2018

I was working in plumsail forms and realized that the style formatting described was for the spforms thus I have swapped over to see if this is more functional and easily customized. In plumsail this code works to hide fields based on checkboxes selected but I cannot figure out how to modify it to work with the spforms.

Code: Select all

//use fd.rendered(function() { for Plumsail Forms instead
fd.spRendered(function() {

    function hideOrShowiTunesInfo() {
        if (fd.field('iTunesAccount').value) {
            // Show the iTunes Info field
            $(fd.field('iTunesAccountInfo').$parent.$el).show();
        } else {
            // Hide the iTunes Info field
            $(fd.field('iTunesAccountInfo').$parent.$el).hide();
        }
    }

    // Calling hideOrShowiTunesInfo when the user changes the Start Date
    fd.field('iTunesAccount').$on('change',hideOrShowiTunesInfo);

    // Calling hideOrShowiTunesInfo on form loading
    hideOrShowiTunesInfo();

});

fd.spRendered(function() {

    function hideOrShowFields() {
        if (fd.field('Equipment').value.indexOf("Mobile Phone")) {
            // Hide the Title field
            $(fd.field('AreaCode').$parent.$el).hide();
        } else {
            // Show the Title field
            $(fd.field('AreaCode').$parent.$el).show();
        }
    }

    // Calling hideOrShowFields when the user changes the Start Date
    fd.field('Equipment').$on('change',hideOrShowFields);

    // Calling hideOrShowFields on form loading
    hideOrShowFields();

});

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Aug 2018

Dear Ben,
We have very similar code in this article, please, check it out - https://spform.com/javascript-framework ... ynamically
Also, you can find more information on getting, setting, and detecting change in fields' values here - https://spform.com/javascript-framework ... eld-values
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests