Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                 <!-- 
these two elements are loaded from Memberstack 
initially and available in the cookie thereafter
--> 
<p id="WMIloaded">61ffb97c85b43c04fec34eba</p>
<p id="membership">"nonprofit"</p>
<p id="demo">hello <span id="greetings"></span></p>

<form>
  <input id="wmid" type="text" name="name" value=""><br>
  <input id="membershipName" type="text" name="name" value=""><br>
  <input id="submit_1" type="submit" value="Submit" class="button">
  
  <input id="submit_2" type="submit" value="Submit" class="button">
  
  <input id="submit_3" type="submit" value="Submit" class="button">
</form>

<!-- cookie.js -->
<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>

              
            
!

CSS

              
                
              
            
!

JS

              
                function getCookie(cname) {
  let name = cname + "=";
  let decodedCookie = decodeURIComponent(document.cookie);
  let ca = decodedCookie.split(';');
  for(let i = 0; i <ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}  

// this Welcome page script sets the cookies on mouseovers
// if the API needs the webflowMemberID 
// use the getCookie("cookie name") function in the header scripts
// let webflowMemberId = getCookie("webflowMemberId")

function mouseOver() {
  document.getElementById("wmid").value = document.getElementById("WMIloaded").innerHTML;
  document.getElementById("membershipName").value = document.getElementById("membership").innerHTML;
  document.getElementById("formName_1").value = "_formName_1";
  document.getElementById("formName_2").value = "_formName_2";
  document.getElementById("formName_3").value = "_formName_3";
  let wmid           = document.getElementById("WMIloaded").innerHTML;
  let membershipName = document.getElementById("membership").innerHTML;
  setCookie(wmid, membershipName);
}

// setcookie on click function source: 
// https://discourse.webflow.com/t/remember-user-input-display-on-all-pages/139923/2
  function setCookie(wmid, membershipName) {
    const dayStored = 3; 
    let cookieString;
    let expiresDate = new Date();
    expiresDate = expiresDate.setTime(expiresDate.getTime() + dayStored * 24 * 60 * 60 * 1000);
    cookieString = "webflowMemberId=" + wmid + "; ";
    cookieString = cookieString +" expires=" + expiresDate + "; path=/";  
    // create cookie on button click to expire on newly defined date
    document.cookie = cookieString; 
    cookieString = "membership=" + membershipName + "; ";
    cookieString = cookieString +" expires=" + expiresDate + "; path=/"; 
    document.cookie = cookieString; 
  } 
// end setCookie()

// check if HELPS-Austin cookies exists
function checkCookie() {
  let wmid = getCookie("webflowMemberId");
  let membershipName = getCookie("membership");
  // returns value or empty string
  if (wmid != "" && membershipName != "") {    
    setCookie(wmid, membershipName);  // resets cookie with new expire date
  } else {
    // set cookies with onmouseover
  }
}
// end checkCookie
window.onload = checkCookie();

document.getElementById("submit_1").addEventListener("mouseover", mouseOver);
document.getElementById("submit_2").addEventListener("mouseover", mouseOver);
document.getElementById("submit_3").addEventListener("mouseover", mouseOver);
// mouseover sets cookie just before clicking ANY button to a domain

              
            
!
999px

Console