How to detect which page is active

I have created a form wich contains two pages. I want to hide or view a certain button, depending on which page is active. So far I understand that the code can be placed in the event «onNavigate» and I can use the macro sc_btn_display to hide or view the button. In adition I need to detect which page is active, so I know when to hide or view the button.

Scriptcase support wrote the following:
«To check the active page, I believe you will need to create a javascript function because the scriptcase tool doesn’t have this functionality nativity."

Please help.

Hi jhstokken,
You could put the following piece of JQuery code in Onscript event of your form:

 ?>
    <script>		
    	$(document).ready(function() {
    		
    		$("#id_form_products_form0").click(function (){
    			alert("Page1 - Show Button");
    			$("#sc_butTest_top").show();
    		});
    			
    		$("#id_form_products_form1").click(function (){
    			alert("Page2 - Hide Button");
    			$("#sc_butTest_top").hide();
    		});

    	});		
    </script>
    <?

id_form_productos_form0 is the name that generates Scriptcase for Page number 1 in form_products
id_form_productos_form1 is the name that generates Scriptcase for Page number 2 in form_products
sc_butTest_top is the name that generates Scriptcase for the custom button created with name “butTest” and located on the top Toolbar in form_products
if you also put the button on bottom Toolbar, SC will name it as sc_butTest_bot

You can verify those names by inspecting them with chrome´s developer console.

My form looks like this:
image

Hope this may help you
Regards,
Mauricio

2 Likes