{"id":1442,"date":"2017-04-12T21:30:43","date_gmt":"2017-04-12T12:30:43","guid":{"rendered":"https:\/\/n8finch2024.local\/?p=1442"},"modified":"2017-05-03T21:49:12","modified_gmt":"2017-05-03T12:49:12","slug":"pass-information-one-page-another-forms-javascriptjquery","status":"publish","type":"post","link":"https:\/\/n8finch2024.local\/pass-information-one-page-another-forms-javascriptjquery\/","title":{"rendered":"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery"},"content":{"rendered":"

This is a quick post, just to share something I learned.<\/p>\n

Recently I got a request to create a simple submit form with a an email input that would direct to another page and take the email address and pre-fill a more complex form with email, name, address, etc.<\/p>\n

Below is the code I used for it.<\/p>\n

<\/p>\n

\r\n\r\n<?php\r\n\/**\r\n* Create a simple shortcode for a newsletter CTA\r\n* Load JS conditionally, only if the page is 'newsletter'\r\n*\/\r\n\r\nadd_action( 'wp', 'n8f_load_rr_signup_cta_scripts_on_newsletter_page');\r\nfunction n8f_load_rr_signup_cta_scripts_on_newsletter_page() {\r\n\r\nif( is_page('newsletter') ) {\r\nadd_action( 'wp_enqueue_scripts', 'register_n8f_rr_signup_cta_scripts' );\r\n}\r\n}\r\n\r\nfunction register_n8f_rr_signup_cta_scripts() {\r\n\r\nwp_enqueue_script( 'n8f_rr_signup_cta_js', get_stylesheet_directory_uri() . '\/js\/newsletter_signup_cta.js', array( 'jquery' ), date("ymd"), true);\r\n\r\n}\r\n\r\nadd_shortcode( 'n8f_rr_signup_cta', 'n8f_rr_signup_cta' );\r\n\r\nfunction n8f_rr_signup_cta() {\r\n$html = '<form action="\/newsletter">\r\n<input type="text" name="email" placeholder="Your email..." \/>\r\n<input type="submit" value="Subscribe"\/>\r\n<\/form>';\r\nreturn $html;\r\n}\r\n\r\n<\/pre>\n

 <\/p>\n

\r\n\r\n\/**\r\n* Parse the url for an email address\r\n*\/\r\n\r\n(function($) {\r\n\r\n$(document).ready(function() {\r\n\r\nvar queryString = location.search\r\nqueryStart = queryString.indexOf("=") + 1,\r\nquery = queryString.slice(queryStart, queryString.length ),\r\ncleanString = query.replace( \/%40\/, "@");\r\n\r\n$('#control_EMAIL').val(cleanString);\r\n\r\n});\r\n\r\n})(jQuery);\r\n\r\n<\/pre>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

This is a quick post, just to share something I learned. Recently I got a request to create a simple submit form with a an email input that would direct to another page and take the email address and pre-fill a more complex form with email, name, address, etc. Below is the code I used […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[1,37,26],"tags":[],"yoast_head":"\nHow to Pass Information from One Page to Another with Forms and JavaScript\/jQuery | Nate Finch<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery | Nate Finch\" \/>\n<meta property=\"og:description\" content=\"This is a quick post, just to share something I learned. Recently I got a request to create a simple submit form with a an email input that would direct to another page and take the email address and pre-fill a more complex form with email, name, address, etc. Below is the code I used […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\" \/>\n<meta property=\"og:site_name\" content=\"Nate Finch\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-12T12:30:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-05-03T12:49:12+00:00\" \/>\n<meta name=\"author\" content=\"Nate\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@n8finch\" \/>\n<meta name=\"twitter:site\" content=\"@n8finch\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nate\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\"},\"author\":{\"name\":\"Nate\",\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\"},\"headline\":\"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery\",\"datePublished\":\"2017-04-12T12:30:43+00:00\",\"dateModified\":\"2017-05-03T12:49:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\"},\"wordCount\":267,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\"},\"articleSection\":[\"Blog\",\"Snippets\",\"What I Learned\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\",\"url\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\",\"name\":\"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery | Nate Finch\",\"isPartOf\":{\"@id\":\"https:\/\/n8finch.local\/#website\"},\"datePublished\":\"2017-04-12T12:30:43+00:00\",\"dateModified\":\"2017-05-03T12:49:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/n8finch.local\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/n8finch.local\/#website\",\"url\":\"https:\/\/n8finch.local\/\",\"name\":\"Nate Finch\",\"description\":\"All the things, keeping it clever...🤓\",\"publisher\":{\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/n8finch.local\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\",\"name\":\"Nate\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg\",\"contentUrl\":\"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg\",\"width\":796,\"height\":792,\"caption\":\"Nate\"},\"logo\":{\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery | Nate Finch","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/","og_locale":"en_US","og_type":"article","og_title":"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery | Nate Finch","og_description":"This is a quick post, just to share something I learned. Recently I got a request to create a simple submit form with a an email input that would direct to another page and take the email address and pre-fill a more complex form with email, name, address, etc. Below is the code I used […]","og_url":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/","og_site_name":"Nate Finch","article_published_time":"2017-04-12T12:30:43+00:00","article_modified_time":"2017-05-03T12:49:12+00:00","author":"Nate","twitter_card":"summary_large_image","twitter_creator":"@n8finch","twitter_site":"@n8finch","twitter_misc":{"Written by":"Nate","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/#article","isPartOf":{"@id":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/"},"author":{"name":"Nate","@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce"},"headline":"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery","datePublished":"2017-04-12T12:30:43+00:00","dateModified":"2017-05-03T12:49:12+00:00","mainEntityOfPage":{"@id":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/"},"wordCount":267,"commentCount":0,"publisher":{"@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce"},"articleSection":["Blog","Snippets","What I Learned"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/","url":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/","name":"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery | Nate Finch","isPartOf":{"@id":"https:\/\/n8finch.local\/#website"},"datePublished":"2017-04-12T12:30:43+00:00","dateModified":"2017-05-03T12:49:12+00:00","breadcrumb":{"@id":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/n8finch-site.site.strattic.io\/pass-information-one-page-another-forms-javascriptjquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/n8finch.local\/"},{"@type":"ListItem","position":2,"name":"How to Pass Information from One Page to Another with Forms and JavaScript\/jQuery"}]},{"@type":"WebSite","@id":"https:\/\/n8finch.local\/#website","url":"https:\/\/n8finch.local\/","name":"Nate Finch","description":"All the things, keeping it clever...🤓","publisher":{"@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/n8finch.local\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce","name":"Nate","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/n8finch.local\/#\/schema\/person\/image\/","url":"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg","contentUrl":"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg","width":796,"height":792,"caption":"Nate"},"logo":{"@id":"https:\/\/n8finch.local\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts\/1442"}],"collection":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/comments?post=1442"}],"version-history":[{"count":3,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts\/1442\/revisions"}],"predecessor-version":[{"id":1477,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts\/1442\/revisions\/1477"}],"wp:attachment":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/media?parent=1442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/categories?post=1442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/tags?post=1442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}