Conditional display (tabs and elements)?

RobertG

Member
Hi,

I created a form using 3 tabs (2 for selecting details, one for summation) to estimate the cost of a stay and one to book it if the client agrees with this quote.

I would like to hide by default the last tab and 3 elements (1 display text and 2 textareas) in the summation group, and allow the visitor to clic an element (button, radio button or else) to display these hidden details.

I didn't find how to hide by default the elements and the tab, and be able to display them after the visitor has chose to book.

I actually tried with radio buttons, set a value zero to "No", a value one to "Yes".
I added JS to hide when the value is <1 and display when the value is 1 but it doesn't work, as if the value of the radio button were not recognised.
May I use a calc element to do this?

Thanks!
 
Thanks,
Thats what I did with JS, but it seems that the value of the radio button is ignored by the JS.
 

Attachments

  • Capture d'écran 2023-06-19 111342.png
    Capture d'écran 2023-06-19 111342.png
    58.2 KB · Views: 66
If you want to hide something on form load you also need a "onload" action.
Radio elements need "onclick"
 
Thanks troester.

With load, click and change actions I can now hide or display the details of a tab.
But the title of the tab remains displayed.
Is there a way to hide the empty tab too?

I have another problem: in the hidden tab I have a calc plugin using the "birth" date plugin (I dindn't tried with the birthday plugin) to determine whether the student will be a minor or of full age during the stay.
As we see in the picture, the student is now no more a minor, so the text below should be hidden.
When I change the date to define it for full age or minor, the validation works but the text remain displayed and I can't find where the error happens.
On a previous version where the tab was always displayed, I didn't have that error.
 

Attachments

  • Capture d’écran 2023-06-20 092322.png
    Capture d’écran 2023-06-20 092322.png
    10.8 KB · Views: 62
Interestingly I fixed this yesterday for my own site. unzip this attachment into your joomla root directory.
 

Attachments

  • formjs.zip
    34.9 KB · Views: 55
Hi,

Another question, please.
On my form I want to add a "form" submit button and display it only if a database join field row is selected (mandatory).
I think it's not possible, so I used a button in the last group. But I don't find what event(s) and what predefined action could do the job, in the JavaSript tab of the element.
Could you explain how to do?
 
Back
Top