Scroll to target and open toggle visibility


#1

Hi,
anyone have a solution for this ? At the top of the page I want to have a button ( for example booking ) and when I click the page scrolls to the end of the page ( it is a single page ) but, I want to use a contact for with a lot of options, and I want to use the toggle visibility option. But when I click the button, the toggle visibility opens, but the client don’t see that …because the contact form is on the bottom of the page and the button at the top of the page…

Is there a way that the page also scroll down by press the button?
thanks a lot
tom


#2

Hello @tom2
Check if is this that you want, I made this page for you with two options:

  1. One button to Scroll and Show Only.

  2. Another Button to Scroll and Toggle…

And I add a close button to the form, so if you choose the Show only, you can close the form if you need.

https://blocs.webtekpc.pt/exemples/tom2/

Hope you like it…


#3

Hi !!
Wow ! That’s it. But I don’t see a difference between this two options ( on a iPad ) …but when clicking the page scroll down and the close button is also perfect …how you do this ??
Thanks a lot :slight_smile:


#4

@tom2

If you press the “scroll and show” it will scroll and open the form bloc. Without close the form, scroll up again and press the same button, you will go to the bottom but the form remain opened.

If you press the “scroll and toggle” it will scroll and open the form bloc. Without closing the form scroll up again and press again “scroll and toggle”, it will scroll but automatically toggle/close the form, if you go up again and press it again, it will scroll and open again.

Try it, I’m on iPad too and everything is working.


#5

@Pealco
Ok, checked …works fine also on a iPad …
I think I need the „scroll and show only“ option …
Thanks tom


#6

Hi @Pealco
Can you please tell me how you do this ? Or send me a Projekt file ?
Thanks Tom :slight_smile:


#7

Yes, as soon as I get my laptop, I’ll send you…


#8

Hello @tom2
There you go:

  1. create a bloc with the form and give it an ID: “hideshow”, then click the visible icon to hide it.

  2. create a html code, and add the following one to add the button with the code to scroll and open the bloc.

<input type="button" id="hideshow" value="Scroll &amp; Show Only" class="bloc-button btn btn-d btn-lg btn-block">
<script>
jQuery(document).ready(function(){
        jQuery('#hideshow').on('click', function(event) {        
             jQuery('#formbloc').show('show');
        });
        $("#hideshow").click(function() {
    $([document.documentElement, document.body]).animate({
        scrollTop: $("#formbloc").offset().top
    }, 2000);
	});
});
</script> 

Hope it will help…


#9

Hi @Pealco
thanks for your help …
I don’t get it to work. think I do something wrong …

  1. I have creat a form. Than give an ID ( where I give the ID - the bloc or the form ? ) I tried both
  2. I have create a Html Brick and put the code inside ? right ?
  3. Is there a way to style the button ? I want to use the button like the blocs option for button “wire” ?
    And the button should have the size of the text … not more. Sorry for my bad English :blush:
    thanks and sorry
    tom

#10

Sorry my mistake wit instructions the ID is not “hideshow” the “hideshow” is the id of the button, the correct ID for the form is: “formbloc” -> sorry my mistake.

And the ID is to the bloc.

About the button they are created with Bootstrap4 conditions, so for this buttons the styles are:

class=“btn btn-outline-primary”
class=“btn btn-outline-secondary”
class=“btn btn-outline-success”
class=“btn btn-outline-danger”
class=“btn btn-outline-warning”
class=“btn btn-outline-info”
class=“btn btn-outline-light”
class=“btn btn-outline-dark”

Then the size:

For Large Buttons add: btn-lg

For Small Buttons add: btn-sm

Check more variables Here.

If you like the buttons you create in the rest of your project, just export your site, edit the html and copy the class that was created in the rest of the buttons, and copy to this one in your project (inside the html code)


#11

Hi @Pealco
your great…works ! In Your example there is a close symbol. In my example not, or I dont see it because my background of the form is really dark … and the grey symbol is not to see :thinking:
Is it possible that I use the same code twice on the page ? Because the second button dont work ( middle of the page ) When I delete the first button the second works :slight_smile:
again, thanks a lot for your help
tom


#12

To create a second button you have to have a different ID, so the code for a second button should be:

 <input type="button" id="hideshow2" value="Scroll &amp; Show Only" class="bloc-button btn btn-d btn-lg btn-block">
<script>
jQuery(document).ready(function(){
        jQuery('#hideshow2').on('click', function(event) {        
             jQuery('#formbloc').show('show');
        });
        $("#hideshow2").click(function() {
    $([document.documentElement, document.body]).animate({
        scrollTop: $("#formbloc").offset().top
    }, 2000);
	});
});
</script> 

About the close button on the form, is a icon, then change the icon to the symbol you want, on the right side the interaction pass it to toggle visibility and put the ID of the form bloc.
Then you have in the same place a color change.


#13

@Pealco
works perfect!!! Thank you so much!
tom