本文介绍了使用javascript将数据从一个HTML页面传递到另一个HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我正在尝试从一个要求用户输入他/她的详细信息的HTML页面传递数据到另一个显示此数据的HTML页面。我正在使用JavaScript来做到这一点。一切正常,但数据没有出现在第二个HTML页面中。 注意:我正在使用ONSEN UI。 我尝试过: JavaScript代码: var allData = []; document.addEventListener(init,函数(事件){ if(event.target.id ==details){ document.getElementById(name)。value = allData [1]; document.getElementById(mobile)。value = allData [2]; document.getElementById(date)。value = allData [3]; document.getElementById(section)。value = allData [4]; document.getElementById(issue)。value = allData [5]; } },false); document.getElementById(Sbtn)。onclick = function(){submitForm()}; 函数submitForm() { //localStorage.clear(); allD ata = []; var a = document.getElementById(name)。value; var b = document.getElementById(mobile)。value ; var c = document.getElementById(date)。value; var d = document.getElementById(section)。value; var e = document.getElementById(issue)。value; allData.push(a); allData.push(b); allData.push(c); allData.push(d); allData.push(e); localStorage.setItem('AllData',allData); var options = { animation:'slide',//使用什么动画 onTransitionEnd:function(){} //完成过渡动画时调用 }; myNav.pushPage(details.html,选项); alert(请检查你的详情); alert( allData); } ------ -------------------- 第二页HTML代码: < ; ons-page id =details> < ons-toolbar>Hi,I'm trying to pass data from one HTML page that asks the user to enter his/her details, to another HTML page that displays this data. I'm Using JavaScript to do that.Everything is working, but the data does not appear in the second HTML page.Note: I'm Using ONSEN UI.What I have tried:JavaScript code:var allData=[""];document.addEventListener("init", function(event) { if (event.target.id == "details") { document.getElementById("name").value=allData[1]; document.getElementById("mobile").value=allData[2]; document.getElementById("date").value=allData[3]; document.getElementById("section").value=allData[4]; document.getElementById("issue").value=allData[5]; }}, false);document.getElementById("Sbtn").onclick= function(){submitForm()}; function submitForm(){ //localStorage.clear(); allData=[""]; var a= document.getElementById("name").value; var b= document.getElementById("mobile").value; var c= document.getElementById("date").value; var d= document.getElementById("section").value; var e= document.getElementById("issue").value; allData.push(a); allData.push(b); allData.push(c); allData.push(d); allData.push(e); localStorage.setItem('AllData', allData); var options = { animation: 'slide', // What animation to use onTransitionEnd: function() {} // Called when finishing transition animation }; myNav.pushPage("details.html", options); alert("Please check your details"); alert(allData);}--------------------------Second HTML page Code:<ons-page id="details"> <ons-toolbar>< ons-back-button>返回<ons-back-button>Back确认 < form> < label>名称: < / label> < label>手机号码: < / label> < label>日期:< ; / label> < label>部分:< / label> < label>问题:< / label> < / form> 你好,{{NAD || 'stranger'}}! 您的手机号码是{{mobile || 'null'}} 您的问题是{{issue || 'null'}} <form> <label>Name: </label> <label>Mobile Number: </label> <label>Date: </label> <label>Section: </label> <label>Issue: </label> </form> Hello, {{ NAD || 'stranger' }}! Your mobile number is {{ mobile || 'null' }} Your problem is {{ issue || 'null' }} 通过Whatsapp分享 Share via Whatsapp推荐答案 这篇关于使用javascript将数据从一个HTML页面传递到另一个HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-09 00:10