Solved

Passing form values to another page with GET or POST

jp1to1
Shopify Partner
3 0 0

Hello, 

I Would like to pass values from a form to another page. 
I tried by using a capture of {{ content_for_header }} with à GET form input but it only works once as all others inputs done afterwards are ignored.  

I also tried with POST form unsuccessfully.

There's my code : 

{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last |
   replace:'\/','/' | 
   replace:'%20',' ' | 
   replace:'\u0026','&'
-%}
{%- unless pageUrl contains "?" -%}{% break %}{%- endunless -%}
{%- assign pageQuerystring = pageUrl | split:'?' | last -%}
{%- assign tag = pageQuerystring | split:'=' | last -%}
{%- assign query_tags = tag | split: "," -%}

{% assign id_input = "1234" | concat: query_tags  %}
 

 

 Is there any way to do it using a GET or POST method ? 
Thanks for your help ! 

Accepted Solution (1)

lspoor
Shopify Partner
6 1 1

This is an accepted solution.

Using FormData you could retrieve the desired content and store it in sessionStorage and check for this on the next page.

View solution in original post

Reply 1 (1)

lspoor
Shopify Partner
6 1 1

This is an accepted solution.

Using FormData you could retrieve the desired content and store it in sessionStorage and check for this on the next page.