You are viewing limited content. For full access, please sign in.

Question

Question

Show or hide a tab in Forms 10.2 using javascipt

asked on January 8, 2018

I like the functionality of the tabs, especially being able to use field rules to show or hide an entire tab.  I have a tab on a form that I need to show or hide depending on what is chosen from a radio button.  Usually this is very straightforward.  But on this form I've passed in a year parameter.  Then in the ready function of my javascript I replace the year in several locations on the form.  This way I don't have to rewrite a new version of this form every year. One of those locations where I insert the year is in the text of this radio button. 

Before the substitution the radio buttons look like this:

This form has the year passed in and then does a few calcs on it to update the year-based placeholders in the form.  When the field above is shown on the live form it looks something like this:

The Field Rule seemed simple enough to create, but upon further inspection the ruling on the field had to be overturned.  Because I substituted 2016 for {twoYearsAgo} in the form, this value doesn't exist in the radiobutton choice any longer, so it can't be chosen.

 

I believe showing/hiding the tab and it's contents will be a two part process.  The first will be showing/hiding the contents of that 'page'.  The second will be showing/hiding the actual tab itself at the top of the form.  I believe I have found the div where the contents live and have that part figured out.  The showing/hiding of the actual tab is stumping me though.  How do I show/hide it?

 

1 0

Answer

SELECTED ANSWER
replied on January 8, 2018

Hi Jamie,

Try this:

$('#form-title-wrap > div > ul > li:nth-child(2)').hide(); //hides 2nd tab
$('#form-title-wrap > div > ul > li:nth-child(2)').show(); //shows 2nd tab
4 0

Replies

replied on January 9, 2018

Thanks!  That worked great!

As suggestion for a future feature...on the Field Rules, if we could choose 'Contains' or 'Does not contain' when working with radio buttons, it would allow the form to run with less custom code and be more native Laserfiche.

 

Thanks!

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.