LogicLooking
LogicLooking

Reputation: 928

Keep a div visible after form submission

I have a div, <div class="sectionCarouselCapabillities"> ... </div> which - by default - is hidden from sight unless you make a change to a drop down. So the following:

    $('.carouselUser').change(function(){
        $('.sectionCarouselCapabillities').show()
    });

States that when select box - with class: carouselUser changes state, we show the div sectionCarouselCapabillities. Great it works.

Problem?

After form submission that div is no longer visible because their is no change to the drop down ...

So what would I have to change to make it appear after change and stay visible AFTER form submision

Upvotes: 0

Views: 970

Answers (2)

meavo
meavo

Reputation: 1042

Instead of using show(), you might want to add a class:

$('.carouselUser').change(function(){
    $('.sectionCarouselCapabillities').addClass('is-active');
});

And in your CSS:

.sectionCarouselCapabillities.is-active { display: block; }

On the server side you can check if the form is posted. If so, add the is-active class on the div already.

Upvotes: 2

Tim
Tim

Reputation: 4099

I think in this case you'll need to set a cookie when the dropdown changes, and then read the cookie after the form submission.

Upvotes: 1

Related Questions