WEB上でjavaを利用した日時の計算、選択した結果表示、クッキーに保存する方法が分かりません文章で説明しにくかと思いますので下記のURLをご覧になって下さいhttp://www.vesta.dti.ne.jp/~uraura/お手数ですが宜しくお願い致します

回答の条件
  • URL必須
  • 1人2回まで
  • 登録:
  • 終了:--
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

回答2件)

id:akibare No.1

回答回数157ベストアンサー獲得回数5

ポイント30pt

とりあえず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;”;

}

id:inokuni No.2

回答回数1343ベストアンサー獲得回数21

ポイント30pt

フォームのデータを元に計算させて、

結果を cookie に書き込むようにすればいいと思います。

コメントはまだありません

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません