Jump to content

Forced form completion before advancing


Pete Foulkes

Recommended Posts

On a 'public on the web' Frog site, I was wondering if there was any way a form could be placed on the homepage that the user must complete before other content is revealed? We're doing our virtual open evening as a public site on Frog but we also want to collect visitor data such as parent name, child name, email address etc. 

Could it be possible with some code that when they hit 'Submit' on the form, it either reveals hidden pages or loads another public Frog site?

 

Link to comment
Share on other sites

This is a tricky one, because Forms can take a while to load in, generally after the HTML widget.  I've had to play around with this on your Frog, search for a site called "Form-based next button"

You'll find two pages, one with a form and one called hidden page.  I used a text widget to get the page link, then used Inspect to copy the href code.

<div style="display: none;" class="pageLink">
<a alt="/frogtrade/form_based_next_button/hidden_page/" data-page-link-cke="/frogtrade/form_based_next_button/hidden_page/" data-cke-saved-href="#" href="#">hidden page</a>
</div>

<script>
    
setTimeout(function(){  
    console.log('ready');
    $('.btn-success').on( "click", function() {
        console.log('getting here');
        var pageLink = $('.pageLink');
        pageLink.show();
    }.bind(this));

}, 5000);
</script>

What is happening here is that the page link is placed inside a DIV, but the style tag hides that DIV from view

Then in the script section, a javascript timer runs, waiting 5 seconds (5000 miliseconds).  After this, the page is scanned for the form's submit button ( it has a class of 'btn-success'.   Once the script knows that button exists, it waits for it to be clicked and then makes the DIV, with the class 'pageLink' visible.  Quite a bit of dressing up needed, but it should work for you.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...