Skip to contents

This function creates a 'Next' button for navigating to the specified next page in a Surveydown survey. The button can be activated by clicking or by pressing the Enter key.

Usage

sd_next(next_page = NULL, label = "Next")

Arguments

next_page

Character string. The ID of the next page to navigate to. This parameter is required.

label

Character string. The label of the 'Next' button. Defaults to "Next".

Value

A Shiny action button UI element with associated JavaScript for Enter key functionality.

Details

The function generates a Shiny action button that, when clicked or when the Enter key is pressed, sets the input value to the specified next page ID, facilitating page navigation within the Shiny application. The button is styled to appear centered on the page. The Enter key functionality is only active when the button is visible.

Examples

sd_next("page2", "Continue to Next Section")
#> <div style="margin-top: 0.5rem; margin-bottom: 0.5rem;">
#>   <button id="next-page2" type="button" class="btn btn-default action-button" style="display: block; margin: auto;" onclick="Shiny.setInputValue(&#39;next_page&#39;, &#39;page2&#39;);">Continue to Next Section</button>
#> </div>
#> <script>
#>     $(document).ready(function() {
#>         var buttonId = 'next-page2';
#>         $(document).on('keydown', function(event) {
#>             if (event.key === 'Enter' && !event.repeat) {
#>                 var $button = $('#' + buttonId);
#>                 if ($button.is(':visible')) {
#>                     $button.click();
#>                     event.preventDefault();
#>                 }
#>             }
#>         });
#>     });
#>     </script>