How to retain the inputbox values when we click on back button | XM Community
Skip to main content

Hi Community,
I'm trying to work with checkbox and input box, the function is to disable the input box when the checkbox is being check, however the problem is when the page back using back button even the checkbox is being check the input box are enabled. How to restore/retain the value
Here when the check is clicked/check the input boxes was disabled
back1.png
However, when I go back using back button even the checkbox is being clicked/check the input boxes is enabled
back2.PNG
The code for disabled the input boxes when the checkbox is being clicked

jQuery('input[type="checkbox"]').on("click",function(){
if(jQuery( "[id='checkboxid']" ).prop('checked')== true)
 {
jQuery(''id="inputboxid1"]').prop("disabled",true).val('');
jQuery(''id="inputboxid2"]').prop("disabled",true).val('');
jQuery(''id="inputboxid3"]').prop("disabled",true).val('');
jQuery(''id="inputboxid4"]').prop("disabled",true).val('');
}
else { 
  jQuery('yid="inputboxid1"]').prop("disabled",false);
jQuery('yid="inputboxid2"]').prop("disabled",false);
jQuery('yid="inputboxid3"]').prop("disabled",false);
jQuery('yid="inputboxid4"]').prop("disabled",false);
}
  });

ricsdpl
Try writing the code on load for that page that if the checkbox is checked disable the text box. Which will execute even if you go back but not when you land on that page for first time.
Hope it helps!


Thank you Deepak!


Leave a Reply