We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30912
    • 463 Posts
    Hello smiley

    So im having to mess with cookies for the first time ever and basically im stuck.

    Im using cookieJar for setting and getting a cookie to display customer content - this works fine and I can achieve the content I want to by hard coding the data.

    However, I need to set the content based on a dropdown list. i have this code:

    <select onchange="if (this.value) window.location.href=this.value">
      <option value="" selected="true">Choose Country</option>
      <option value="/" [[!setCookie? &name=`Location` &value=`UK` &expires=`3600`]]>Europe</option>
      <option value="/" [[!setCookie? &name=`Location` &value=`US` &expires=`3600`]]>United States</option>
    </select>
    


    So it sets the location cookie and redirects to reload the page, however the cookie that is set is NOT the selected cookie, rather the last one in the list. This was tested by adding a third value to the select and that value always set.

    Im sure there is a much easier way to set a cookie based on dropdown but JS and Cookies are not my forte

    Any help is appreciated.