I have two js files and two html forms. In the first form there are two radio buttons, upon selection of a radio button the user clicks on continue button to move to the next page (this is the second form). I need to disable a particular section of the second form based on the radio button selected in the first form.
Is it possible to get the value of checked radio button from the first form onto the second form in js?
CodePudding user response:
I don't know if this is the best way, but you can use url parameters
.
location.href = 'https://www.example.com/?radioButton=2'
And on the other side,
let previousRadioButton = /(?<=radioButton=)\d /.exec(location.href)[0]
CodePudding user response:
There are two methods you can do this
Cookies
You can make a session cookie and add the radio button choice to it, then parse it on the next page!
As requested, with jQuery:
On page 1:
$.cookie("options", `form1_radio={option}`)
On page 2:
alert($.cookie("options"))
Parameters
You can pass the option in a URL parameter to the next page!