I have a section in my form that can be repeated.
I am hoping there is a way to hide the add section label (Click here to add another type) if two date fields higher in the form are the same.
Cheers
Ross
I have a section in my form that can be repeated.
I am hoping there is a way to hide the add section label (Click here to add another type) if two date fields higher in the form are the same.
Cheers
Ross
Hi, Ross.
You can do this with Javascript. I assume the section you're talking about is a collection.
Create a function and call it whenever either of the two fields change:
$('.fieldoneclass input').on('change', hideAppendLink);
$('.fieldtwoclass input').on('change', hideAppendLink);
function hideAppendLink() {
var field1Val = $('.fieldoneclass input').val();
var field2Val = $('.fieldtwoclass input').val();
if ( field1Val == field2Val ) {
$('.collectionclass .cf-collection-append').hide();
}
Replace fieldoneclass, fieldtwoclass, and collectionclass with the classes you assigned those fields.
Hi Sheila,
Thanks for the reply, and yes I am talking about collections!! Thanks for picking that up.
I inputted the Javascript and added the class names but the label is still there when I run the form and put in the same dates.
Screenshot below and attached, did you have any ideas why this is not working? Once again thanks for your help....
Sorry, Ross. I missed a closing curly brace at the end. Add "}" at the end to end the function and you should be good to go.
Hi Sheila,
Added the curly bracket at the end and still not hiding the add another collection when the dates are the same.
Any other ideas?
Thanks for all your help.
Cheers
Ross
Sorry, Ross. I just saw your post. If you still need help, let me know.
I notice in your image, you don't start your javascript with the "on ready" function, which you need to do. You need to put all of you javascript between the opening and closing:
$(document).ready(function() {
<your code goes here>
});
By the way, Laserfiche provided some great documentation for getting started with Javascript in Forms and they have some examples of functions that you can look at. Clicking on the "Learn More" link in the Javascript pane will take you to the examples and at the bottom of that is a link to "Getting Started with Javascript in Laserfiche Forms".
Not having used Javascript before and being rusty at programming, that's how I got started. Between various websites and the people who post here, I've been able to figure out how to do everything I've needed to do.