I tried to follow this example;
Set to true state a checkbox in a different page(javascript)
but can't get it to work, not sure how to fix it?
Getting error message;
Request Method: GET
Request URL:
http://localhost:8000/profileusers/register.html?chk=1"
First Page - terms.html
<div class="row">
<a href="{% url 'register' %}" target="_blank">
<input type="button" name="acceptButton" class="btn accept-button" value="Accept" id="acceptButton" onclick="registerCheck(this.id)">
</a>
<a href="{% url 'register' %}">
<input type="button" name="declineButton" id="declineButton" class="btn decline-button" value="Decline">
</a>
</div>
<script>
function registerCheck(clicked_id) {
if (clicked_id === 'acceptButton') {
window.location.href = "register.html?chk=1";
}
}
</script>
Second Page - register.html
<div class="form-check">
<input class="form-check-input" type="checkbox" id="terms-box" name="terms-box">
<label class="form-check-label" for="flexCheckDefault">
<a href="{% url 'terms' %}" class="link-terms">Terms & Conditions</a>
</label>
</div>
<script>
var url = window.location.href.split("?");
if (url[1].toLowerCase().includes("chk=1")) {
$('#terms-box').attr('checked', true);
}
</script>