var newMeal = document.getElementsByName('groceries');
var expires = new Date();
expires.setTime (expires.getTime() + 24 * 60 * 60 * 1000);
var expiryDate = expires.toGMTString();
function newCookie(add,newMeal) {
document.cookie = add + "=" + newMeal + "; expires=" + expiryDate;
}
function toShoppingList() {
window.location = "http://www.whatsfordinner.net/Testing-Insert-div.html";
}
<div id="groceries">
Shopping list for a new meal
</div>
<form onClick="toShoppingList();" "newCookie();">
<input type="button" value="Add this meal to my menu and shopping list">
</form>
Code language: JavaScript (javascript) If it is possible to carry the entire div with a cookie, I now need to write the cookie function to read the data. Since I had success with the previous getCookie, I altered that function for the new variable Code language: JavaScript (javascript) function getCookie(add) { var cookieFound = false; var start = 0; var end = 0; var cookieString = document.cookie; var i = 0; //Scan the cookie for add while (i <= cookieString.length) { start = i; end = start + add.length; if (cookieString.substring(start,end) == add) { cookieFound = true; break; } i++; } //Is add found? if (cookieFound) { start = end + 1; end = document.cookie.indexOf(";",start); if (end < start); end = document.cookie.length; return document.cookie.substring(start,end); } return ""; } [/code] Then I put this javascript into the body where I was hoping the div information would appear. [code="javascript"] document.write(addIt) [/code] Of course, it couldn't be that simple, could it? I would love to hear from someone who has been successful in moving information across pages. Is there a fix to the codes I have written, or is there a better way to do this? Thanks so much. Side note: I realize that there is a lot more to be done with a meal planning site that involves creating a database. I do plan to establish that and use it to create much more interactivity. Meanwhile, after 5 years of building traffic and attracting spatters of media attention, I feel the urgent need to make a change that can immediately increase user interactivity. This javascript meal switch is something that I can do with all the recipes as they currently appear in html. It is also a good way for me to gain skills and build some confidence. :) Jean Fisher What's For Dinner? Make dinner time, family time! http://www.whatsfordinner.net Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…