Set checkmark and button to default when clicking page back

Do you want to share WYSIWYG Web Builder tips, tricks, tutorials or useful HTML code? You can post it here...
(no questions or problems please, this section is not monitored by support).
Forum rules
This section is to share tips, tricks and tutorials related to WYSIWYG Web Builder.
Please do not post questions or problems here. They will not be answered.

PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
Post Reply
martin.mattel
 
 
Posts: 83
Joined: Thu Oct 04, 2018 3:04 pm

Set checkmark and button to default when clicking page back

Post by martin.mattel »

This code snipplet may help setting a checkmark and button to a default state when pressing "back" in the browser menue.
It is important that the browser does not remember the former state.
This example is extendable with any buttons, checkmarks, radiobuttons ect.

Example
page1:
set checkmark which enables the button,
press the button,
you are directed to page2
page2:
somthing fails or whyever you press back to return to page 1,
the settings should be set to default

Code: Select all

<script type="text/javascript">
  document.getElementById("contactCheckbox1").autocomplete = "off";
  document.getElementById("contactCheckbox1").addEventListener("change", function(){
    if(document.getElementById("contactCheckbox1").checked){
      enable_send_button();
    } else {
      disable_send_button();
    }
  });
  $(window).bind("pageshow", function(){
    disable_send_button();
  });
  function enable_send_button() {
    document.getElementById("contactAdvancedButton3").style.borderColor = "#32CD32";
    document.getElementById("contactAdvancedButton3").style.backgroundColor = "#32CD32";
    document.getElementById("contactAdvancedButton3").disabled = false;
  }
  function disable_send_button() {
    document.getElementById("contactAdvancedButton3").style.borderColor = "#A9A9A9";
    document.getElementById("contactAdvancedButton3").style.backgroundColor = "#A9A9A9";
    document.getElementById("contactAdvancedButton3").disabled = true;
  }
</script>
Post Reply