2 つの HTML ファイルと 1 つの JavaScript ファイル、index.html、results.html、file.js があります。
index.html 内では、javascript ファイル内でいくつかの計算を行うために使用されるユーザー入力を取得します。ボタンを押すと計算が始まります。index.html から取得したデータを results.html に表示したいので、ボタンを押すと関数が実行され、別のページに移動します。
結果を1ページに計算して表示することはすべて正常に機能しますが、結果をresults.htmlに表示する方法がわかりません。
コードの一部は次のようになります。
function berekenKoolBehoefte(){
koolBehoefte = (energieBehoefte - (eiwitBehoefte * 4) - vetBehoefte) / 4;
toonKool();
}
function toonKool(){
var uitkomstKool = document.getElementById("uitkomstKool");
uitkomstKool.innerHTML = (koolBehoefte * 4).toFixed(1) + " kcal" + " " + koolBehoefte.toFixed(1) + " gram"
}
bereken.addEventListener('click', berekenKoolBehoefte, false);
これはすべてを 1 ページに表示します。関数 toonKool() は results.html 内に表示する必要があります。