這是工作中的參考數字我想給我的形式工作中的參考文本框:傳遞文本從一個頁面到下一個使用JavaScript
<p><span id="job" value="90192"><strong>Reference Number: 90192</strong></span></p>
//when this link will be clicked it will redirect to apply.html with job value stored in session.
<a href="Apply.html" class="button-apply" id="apply3">Apply Here</a>
<p><span id="job2" value="90192"><strong>Reference Number:90192</strong></span></p>
//when this link will be clicked it will redirect to apply.html with job value stored in session.
<a href="Apply.html" class="button-apply" id="apply2">Apply Here</a>
的JavaScript jobs.js
文件:
"use strict"
function storedata() {
var job = document.getElementById("job").value;
var job2 = document.getElementById("job2").value;
var job3 = document.getElementById("job3").value;
sessionStorage.job = job;
sessionStorage.job2 = job2;
sessionStorage.job3 = job3;
}
function init() {
var apply = document.getElementById("apply");
var apply2 = document.getElementById("apply2");
var apply3 = document.getElementById("apply3");
apply.onclick = storedata;
apply2.onclick = storedata;
apply3.onclick = storedata;
}
window.onload = init;
這裏我想存儲從apply.html
開始的作業參考號碼:
<label for="Job">Job Reference Number</label>
<input type="text" name="Student ID" id="Job" norequired="norequired" pattern="\d{5}" />
<br />
<br />
這是讓我的JavaScript函數sessionStorage
在apply.js
:
function retrievedata() {
document.getElementById("Job").value = sessionStorage.Job = Job;
}
問題是,當點擊來自jobs.html申請鏈接會重定向到apply.htm在作業參考號碼將被存儲,但它是不會發生
什麼問題呢?? –
問題是,當點擊應用從jobs.html鏈接它將重新申請。htm作業參考號碼將被存儲,但不會發生 –
您是否真的想要將點擊的所有值存儲起來,而不僅僅是您點擊的那個值? – epascarello