I looked into the forum but I believe it’s Jquery related but I couldn’t find a suitable solution.
I’m building a website where you can rate cities. Each cities page have a button that lead to a form page to rate it.
I would like for the form to populate with the city name (from the previous page). It has to have the exact same name because when the form is submited, the data imputed go in a CMS collection (via Zapier) and has to match the right city.
Hey @Nick101, I would use localStorage() for this. Code will look something like this.
$(window).on('load', function(){
localStorage.setItem('city', $('.city-name').val())
})
and on the form page.
$(window).on('load', function(){
$('.input#cityname').val(localStorage.getItem('city'))
})
I wrote that on the fly, if there are any errors let me know
@dennyhartanto Had the same question as Nick101 above, not sure which variables to change to make it work on my page. I can kind of follow but get lost with the ‘.____’ values.
I’m trying to collect an address on landing page and then use it to populate address field on the next page the CTA clicks through to. If it helps the text input field (on both pages) is “address”
Is the way I’ve updated below correct? Thanks in advance!
Copy the following snippet into initial capture page code:
I have a text input field on the landing page where the user can fill in their Address. When they click submit, it takes them to a separate form for them to fill out additional information. I’d like the Address field on this new form to be already filled out with what they entered on the landing page. Is this something I can do with localStorage?
Hey Denny thanks so much for the reply. Unfortunately I couldn’t get it to work.
I replaced ‘.input#address’ with ‘.input#propertyAddress’ but otherwise left everything else the same (propertyAddress is the ID of the field on the contact form). I put these snippets “before tag” on both the landing page and Contact page.
Your syntax looks different than other examples I’ve found online but I figured there could be multiple ways to write it. Any other thoughts on what I might need to change?
Hi @Brett_Mecham, I’m not 100% sure this is the issue. but I think the single quote marks were copied correctly from the forum post. The stuff in ‘…’ should be green like #gpa. so I’ve added a new code for you to try. Also note that Element IDs are case sensitive so .input#propertyAddress should be .input#Property-Address