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

Question

Question

Help WIth CSS & Javascript

asked on November 20, 2019

*Disclaimer- I am pretty much a beginner at the whole CSS/JS thing. I currently and taking some self-teaching courses (w3Schools and Pluralsight)*

 

I have a form in which I embedded the LF repository using iFrame. I like how it looks and it seems like a great solution to a problem I am solving. However, I want to take it up a notch and incorporate a button that display/hide the iFrame when clicked. 

 Just in case it helps I added the iFrame to the form as a custom HTML field. ( I will include screenshots below)

 

iFrame setup

 

Below is where I have the field currently hidden

Any help would be great. Thanks

 

 

0 0

Replies

replied on November 20, 2019

Well, you can either go with the custom JavaScript option, or you could go the "easy" route.

With the "easy" route you could just put your customHTML into its own Section, then in the configuration for the section allow the users to show/hide the section. That way they could just click the section header and it will expand/collapse with a nice animation and everything.

If you don't like how that looks, we can go from there and look at some JavaScript lol.

3 0
replied on November 20, 2019

Hey Jason, I definitely think that the option for the section would be the simplest/quickest way to get what I want off the ground. However, if you don't mind I'd love to look at the Javascript examples you could provide (since I am trying to acclimate myself more to that)

0 0
replied on November 20, 2019

I don't have any pre-made examples, but Forms loads the JQuery libraries which makes the process of showing and hiding things pretty simple.

Personally, instead of hiding the entire customHTML element (#q44) I would add an ID attribute to the iframe and only hide that; this way you can put the button in the same CustomHTML element, just be sure to give it an ID as well.

Then do something like,

$(document).ready(function(){
    $('#myButton').on('click',function(){
        // check if frame is visible        
        if($('#myFrame').is(':visible')){
             $('#myFrame').hide();
        }
        else{
             $('#myFrame').show();
        }
    });
});

The example above is for a "toggle" button, but you could do separate buttons and just hide the appropriate one along with the frame and ditch the if/else.

If you do a toggle, you could also update the button text inside the function. I kept the example simple because the exact code is going to vary depending on the approach you choose, what type of button, etc.

2 0
replied on November 20, 2019 Show version history

Thanks a lot, Jason! I will give this a try. 

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

Sign in to reply to this post.