1
ボタンをクリックすると、フォームページにリダイレクトされ、特定の詳細が入力されます。このデータを取得し、セッションオブジェクトを使用してローカルに格納する必要があります。セッションデータを使用してデータを保存する
ボタンコード:
<form action="Enquiry.html" method="get">
<button class="button1" id="CreamLx">Book Now!</button>
</form>
フォームページ:
<form method="post" action="" class="form1">
<p>
<label for="Products">Products</label>
</p>
<select name="Products" id="Products" required="required">
<option value="">Please Select</option>
<option value="Cream1">Creamy</option>
</select>
</form>
JavaScriptコード:
"use strict";
function validate(){
var errMsg = ""; // stores the error message
var result = true; // assumes no errors
if (result){
storeProduct(CreamLx);
}
return result;
}
function storeProduct(CreamLx){
sessionStorage.CreamLx= CreamLx;
}
function getProduct(CreamLx){
if(sessionStorage.CreamLx!= undefined){
document.getElementById("CreamLx").textContent = sessionStorage.CreamLx;
document.getElementById("CreamLx").value = sessionStorage.CreamLx;
}
}
function init(){
var car=document.getElementById("car");
var option = document.getElementById('Products').value = product;
}
window.onload = init;
私が間違って行くのです
?私のJavaScriptは動作していません。
質問が不明です。 'validate()'が呼び出されることはありません。このコードが何を期待していますか? – Kashif
基本的には、ボタンをクリックすると自動的にこのがフォームページに選択されます。情報を保存し、セッションストレージを使用して情報を取得する必要があります。 – Detonator
javascriptには「セッションストレージ」はありません。 'localStorage'を意味しますか? – Kashif