I need to save a string inside the textbox, and to make it happen so, when the "Set as default" -box is checked and when the button is pressed, the input of the ID will be saved as a cookie to the user. IE. I'll type "TEST" and the next time I open the app, it will remember the input that was typed in & searched.
I will provide an image from the UI, so you will get basic understanding how it looks like;
I have two sides on the project; (exclusing CSS) JS and HTML. Currently my code in cookie.js looks following;
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
}
function checkCookie() {
}
I havent really tried anything specific, I've tried to work with checkCookie and getCookie functions to get this work but so far without result.
In HTML, I've only coded following inside the body;
<body id="body" style="max-height: 100%;" onload="checkCookie()">
<form onsubmit="return false" id="searchform">
<input type="text" id="field" placeholder="Search timetable"
maxlength="100" autocomplete="off">
<label for="setDefault" id="mlabel"><input type="checkbox"
id="setDefault" data-role="none" />Set as default</label>
<input type="button" value="Search" id="search"
class="ui-btn ui-input-btn
ui-corner-all ui-shadow" onclick="executeSearch()" />
</form>
</body>
So my question is; How can i store the string that I've typed inside textbox and how can I get the value when I open the page again?