I have looked around and not found anything too useful as to how I can do this, so sorry if it's a repeat question.
I am trying to get it so if a user clicks a certain link, they will be sent to a page with a checkbox pre-checked.
For example, I have 3 categories
PSHE, Food and EHWB.
I have a page that has all post's with these categories on but with filters that only show the categories selected.
I want to have 3 links on the homepage, that if clicked, load the page with the checkbox of the corresponding link pre-checked.
What's the best way to do this?
All I haven't found so far is this:
$('input[type=checkbox').click(function(){
window.location.hash = $(this).val();
});
This add's the value of the checkbox to the URL when clicked, i'm not sure if this is a stating point but any help would be appreciated. Thanks.
EDIT:
Here is my HTML as requested.
<fieldset id="filters" class="form__section form__section--group form__section--categories">
<legend class="form__section__title">
<h2 class="form__section__title__text">Filter by category:</h2>
</legend>
<div class="form__item form__item--boolean form__item--checkbox">
<button type="button" value=".all" id="checkAll">All</button>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-food" value=".category-what-food" id="category-what-food ff-checkbox-1" class="checkbox1" /><label for="category-what-food ff-checkbox-1">Food</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-pshe" value=".category-what-pshe" id="category-what-pshe ff-checkbox-2" class="checkbox1" /><label for="category-what-pshe ff-checkbox-2">PSHE</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-sex-education" value=".category-what-sex-education" id="category-what-sex-education ff-checkbox-3" class="checkbox1" /><label for="category-what-sex-education ff-checkbox-3">Sex Education</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-physical-education" value=".category-what-physical-education" id="category-what-physical-education ff-checkbox-4" class="checkbox1" /><label for="category-what-physical-education ff-checkbox-4">Physical Education</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-ehwb" value=".category-what-ehwb" id="category-what-ehwb ff-checkbox-5" class="checkbox1" /><label for="category-what-ehwb ff-checkbox-5">EHWB</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-environment" value=".category-what-environment" id="category-what-environment ff-checkbox-6" class="checkbox1" /><label for="category-what-environment ff-checkbox-6">Environment</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-policies" value=".category-what-policies" id="category-what-policies ff-checkbox-7" class="checkbox1" /><label for="category-what-policies ff-checkbox-7">Policies</label>
</div><!--/form__item-->
<div class="form__item form__item--boolean form__item--checkbox">
<input type="checkbox" name="ff-checkbox category-what-governors" value=".category-what-governors" id="category-what-governors ff-checkbox-8" class="checkbox1" /><label for="category-what-governors ff-checkbox-8">Governors</label>
</div><!--/form__item-->
</fieldset><!--/form__group-->