JavaScript   

Update URL param value with the textbox value in realtime using JavaScript

This is an example snippet for updating URL param value using pure JavaScript.  URL param value will be get updated in the realtime as the user starts typing in the textbox.

function updateURLParam() {
	let queryParams = new URLSearchParams(window.location.search);
	let emailVal = document.getElementById("email").value;	
	queryParams.set("email", emailVal); //email is URL param name
	history.replaceState(null, null, "?"+decodeURIComponent(queryParams));
} 

 

<input type="email" id="email" onkeyup="updateURLParam()">
Need Professional Support for Your Website Problems?

Whether you're facing website issues or struggling with code implementation, our team is here to assist. Hire us to get your website back on track.

Hire Us