Example 1. Using a link
page 1
Change WhateverItIsYouArClicking
to #link
if what you are clicking has id="link"
or ".someClass"
if what you are clicking has class="someClass"
window.addEventListener("load",function() {
document.querySelector("WhateverItIsYouArClicking").addEventListener("click",function(e) {
e.preventDefault(); // if it is a link or a submit button
const fields = [...document.querySelectorAll("input[type=number]")].map(fld => fld.id+"="+fld.value);
location = "index.html?"+fields.join("&");
})
})
Page 2
window.addEventListener("load",function() {
const url = new URL(location.href);
document.querySelector(".rooms_amount_bedroom").textContent = url.searchParams.get("rooms_amount_bedroom");
document.querySelector(".rooms_amount_bathrooms").textContent = url.searchParams.get("rooms_amount_bathrooms");
document.querySelector(".rooms_amount_kitchens").textContent = url.searchParams.get("rooms_amount_kitchens");
})
Example 2 using a form
<form action="index.html">
<input type="number" id="rooms_amount_bedroom" autocomplete="off" value="0">
<input type="number" id="rooms_amount_bathrooms"autocomplete="off" value="0">
<input type="number" id="rooms_amount_kitchens" autocomplete="off" value="0">
<input type="submit" />
</form>
and on page 2 have the same as above