• Resolved nsperfeld

    (@nsperfeld)


    Hi,

    I have 2 calculators, one for Dogs and another for Cats.

    I`m aiming to build a page with both, and a Button to choose one of the two that shows the chosen calculator.

    One rudimentary solution would be to put the two calculators on the page and use an Anchor link to go to the selected calculator.

    There is a better solution within the plugin?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @nsperfeld

    There are different alternatives, and you should select the preferred solution to your project.

    An alternative would be to implement only one form, with a radio buttons fields to select between dogs or cats, and display the corresponding fields using dependencies. More information about dependencies reading the following post in the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/06/01/csv-generator-google-sheet/

    Another alternative would be to insert both forms’ shortcode into the page’s content, each of them with their own class name, for example: [CP_CALCULATED_FIELDS id="1" class="cat"] and [CP_CALCULATED_FIELDS id="2" class="cat"] (the forms’ ids are hypothetical, only to describe the process), and then you can define these class names through the: “Appearance > Custom > Additional CSS” option in the WordPress menu for hiding both forms by default:

    
    .cat, .dog{display:none;}
    

    And finally insert two buttons in the page, for dogs and cats, with the following pieces of code as their onclick events:

    For the dogs button:

    
    jQuery('.dog').show();jQuery('.cat').hide();
    

    and for the cats button:

    
    jQuery('.dog').hide();jQuery('.cat').show();
    

    Best regards.

    Thread Starter nsperfeld

    (@nsperfeld)

    Hii,

    Thanks for the fast answer. I will go for the alternative one so, use the dependencies. But the problem now is: I’ve created the first Dependence with a Radio button, to show all the next fields when selecting the Cat or Dog.

    But on the Preview, when I select one of them, all the other fields from that dependence shows. But they were intended to follow their own dependencies too.

    It’s like when the first dependence is resolved, all the rest just are ignored and every single field is shown.

    How can I work this out?

    Sorry If I`m hard to understand, English isn’t my first language.

    Plugin Author codepeople

    (@codepeople)

    Hello @nsperfeld

    If you are using dependencies, and they have multiple levels, you should to configure only the dependency rules corresponding to each level.

    For example, assuming you have a radio button field for dog, and cat, and then, a new level to display the additional fields depending on the animal genre.

    The radio button for the animal, should to include the dependency rules for the genders fields, for dogs and cats, and then, in the gender fields you should to include the corresponding dependencies for the other fields.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can I use Dependences to show 2 calculators on the same page?’ is closed to new replies.