There are 2 pages. The first one contains one button, and the second one checkbox (by default it is not pressed). When you click on the button, you must redirect to the second page (for example, through window.location) and activate the checkbox. Already suggested that you can use data attributes, but still do not really understand how to activate the checkbox.
1 answer
This can be easily achieved with the help of URL arguments. On the first page we add a parameter to the link address, for example: .../view_page?need_check=1
On the second page, using JavaScript, we check the parameter and, if available, set the checkbox in the checkbox:
// просто функция для извлечения аргумента url'a function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } } // извлекаем и проверяем параметр var need_check = false; if (window.location.href.includes('need_check')) need_check = +getUrlParameter('need_check') > 0; // устанавливаем значение чекбокса $("#ch_split").prop("checked", need_check); |