简体   繁体   English

我如何从一个页面到另一个页面获取数据,只需使用JavaScript在屏幕上简单显示

[英]How do i get data from a page to other page,just simply display on screen with javascript

 <style>div.container { max-width: 800px; max-height: 800px; display: inline-block; } 
 <body> <h1>Your Selection</h1> <p>Here is the information you have submitted:</p> <div class="container"> <ol> <li><em>AID:</em> <?php echo $_POST['aid']?> </li> <li><em>Date of Arrival:</em> <?php echo $_POST['Arrival']?> </li> <li><em>Number of Days:</em> <?php echo $_POST['Days']?> </li> <li><em>Number of Adults:</em> <?php echo $_POST['adults']?> </li> <li><em>Number of Children</em> <?php echo $_POST['children']?> </li> <li><em>Total:</em> <?php echo $_POST['Total']?> </li> </ol> </div> <div class="container" align="left"> <form action="" method="post"> Name : <input type="text" name="name" placeholder="Full Name" /><br> Phone Number : <input type="number" name="number" placeholder="Phone Number" /><br> Email : <input type="email" name="Email" placeholder="Email" /><br> Address : <input type="text" name="Address" placeholder="Address" /><br> <input type="submit" value="Confirm"> <input type="submit" value="Cancel"> </form> </div> </body> 

As the code runs it will print out the information that user already select and type previously. 代码运行时,它将打印出用户已经选择并键入的信息。 Whenever the user clicks on submit, it will turn to receipt page and list the data on the screen. 每当用户单击“提交”时,它将转到收据页面并在屏幕上列出数据。

You can use for example window.location() and send the data you want to display in the Query String. 您可以使用例如window.location()并发送要在查询字符串中显示的数据。 ie: 即:

window.location = "http://www.home.com/page/?info=whateverYouNeed";

And then you can get the query string with: 然后,您可以使用以下命令获取查询字符串:

window.href.url  

There are numerous ways of doing this including using ajax to post to the backend and then retrieve it using ajax get request from the data destination page. 有很多方法可以做到这一点,包括使用ajax发布到后端,然后使用ajax get请求从数据目标页面检索它。

I hope I understood your question right and that the answer was appropriate. 我希望我理解您的问题是正确的,并且答案是正确的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用javascript从单选按钮获取结果并将其显示在最后一页? - How do I use javascript to get the result from radio button and display it at the last page? 如何从第三方API提取数据并使用javascript将其显示在我的页面上? - How do I extract data from a 3rd party api and display it on my page with javascript? 如何使用 javascript 从表单存储数据并将其显示在新页面上? - How do I store data from form and display it on a new page using javascript? 如何使用jquery或javascript将图像从页面的一侧滑动到另一侧? 就像在thepiratebay.se上一样 - How to get an image to slide from one side of page to the other with jquery or javascript? Just like on thepiratebay.se 如何显示一页到另一页的数据? - How do i display a data from one page to another? 如何将第1页的输入字段传递给第2页的隐藏字段,然后在javascript中显示第2页到第3页的隐藏字段? - How do I pass input fields from page 1 to hidden fields on page 2 and then display hidden fields from page 2 to page 3 in javascript? 从 javascript,我如何访问提交的响应页面 - From javascript, how do I get access to the response page of a submit 如何使用 JavaScript 从 div 中提取数据,并显示在同一页面内的其他 div 中(引导模式) - How to extract data from div, and display in other div within same page (bootstrap modal) using JavaScript 如何委派某些javascript(呈现页面)以具有比其他javascript(获取数据)更高的重要性 - How do I delegate some javascript (rendering the page) to have higher importance then other javascript (fetching data) 如何通过javascript将值从一页传递到另一页,并使用php获取另一页中传递的值? - How to pass values from one page to other page by javascript and get the passed value in the other page using php?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM