http://msdn.microsoft.com/library/default.asp?url=/library/en-us...
split Method (Windows Scripting - JScript)
とりあえずCookieを保存して取り出す方法です。Bodyのonload=LoadData()に設定して、「設定」ボタンのonclick=SaveData()とします。GetCookieの効率が悪いですが改良してください。
function SaveData()
{
SetCookie(”date0”, document.forms[0].date0.value);
SetCookie(”mainte0”, document.forms[0].mainte0.value);
SetCookie(”date1”, document.forms[0].date1.value);
SetCookie(”mainte1”, document.forms[0].mainte1.value);
SetCookie(”select_1”, document.forms[0].select_1[0].checked ? ”a” : ”b”);
document.location.reload();
}
function LoadData()
{
alert(document.cookie);
document.forms[0].date0.value = GetCookie(”date0”);
document.forms[0].mainte0.value = GetCookie(”mainte0”);
document.forms[0].date1.value = GetCookie(”date1”);
document.forms[0].mainte1.value = GetCookie(”mainte1”);
document.forms[0].select_1[0].checked = (GetCookie(”select_1”) == ”a”);
document.forms[0].select_1[1].checked = (GetCookie(”select_1”) == ”b”);
}
function SetCookie(key, val)
{
document.cookie = key + ”=” + escape(val);
}
function GetCookie(key)
{
var strCookie = document.cookie;
var fields = strCookie.split(”; ”);
for (i = 0; i < fields.length; i++)
{
var pair = fields[i].split(”=”);
if (pair[0] == key)
{
return unescape(pair[1]);
}
}
}
function DeleteCookie(key)
{
document.cookie = key + ”=;expires=Fri, 31 Dec 1999 23:59:59 GMT;”;
}
フォームのデータを元に計算させて、
結果を cookie に書き込むようにすればいいと思います。
コメント(0件)