hey, so ive been trying to create an array of newly created articles and save it on the session.
on the article creating form i did something like that:
and in the page that the display of the array should be i wrote:Code:var createdArticles = new Array(); createdArticles[0] = $("#title").val(); createdArticles[1] = $("#subtitle").val(); createdArticles[2] = $("#content").val(); createdArticles[3] = $("#name").val(); var jsData = JSON.stringify(createdArticles); sessionStorage.setItem("allData" , jsData); window.location.href='Home.html';
its not working for me, im using ref to json_parse.js and to json2.js.Code:var createdArticles = new Array(); var jsCreatedArticles = sessionStorage.getItem("allData"); var createdArticles = JSON.parse(jsCreatedArticles); for (var i=0; i < createdArticles.length , i++) { var newArticle = "<article><header><hgroup><h1> " + createdArticles[0]+ "</h1><h2> " + createdArticles[1] + "</h2></hgroup></header><p> " + createdArticles[2] + "</p><footer><p> -Written by " + createdArticles[3] + "</p></footer></article>"; $("#main_section").append(newArticle); }
any ideas? thanks![]()


Reply With Quote

Bookmarks