You could accomplish that in a few ways.
- add the value to the redirect url.
- save the value in a cookie
- save the value in a server side session
- save the value client side in local storage
You could accomplish that in a few ways.
You can make use of client side localStorage or sessionStorage
in page 1,
<input type="text" id="1" value="">
<button onclick="save();">Save now</button>
in your javascript file, put this:
function save(){
var inputValue=$('#1').val();
sessionStorage.setItem('save', inputValue);
location.href='link to second page'
}
//In page two, you can do whatever you want with the saved value, in js file
alert( sessionStorage.getItem('save') );
you can do this thing by using the js local storage here below is code in jquery and javascript, both will work charm
Pure Javascript
<input type="text" id="localstore">
<button onclick="savelocal()">Save</button>
<script>
document.getElementById("localstore").value = localStorage.getItem("inputval");
function savelocal(){
var loc = document.getElementById("localstore").value;
localStorage.setItem("inputval", loc);
window.location.href = "http://yourpath/page2";
}
</script>
with Jquery
<input type="text" id="localstore">
<button class="saveto">Save</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$('#localstore').val(localStorage.content);
$('.saveto').on('click', function(){
localStorage.content = $('#localstore').val();
window.location.href = "http://yourpath/page2";
})
</script>
I have 2 webpages. They both have on them.
User starts on Page1. If user types “cat” into Page1 input box, I want user to be redirected to Page2 with ‘cat’ automatically filled out in Page2 input box.
Possible at all with jQuery/JavaScript? I’m guessing no, but thought I would ask.