将数据从1页传递到另一页 [英] Passing data from 1 page to another
问题描述
嗨
我有一个函数可以在数据中返回值
Hi
I have a function that returns value in "data"
var successF = function (data) {
var eventID = data;
var url = '/Admin/AddEvent.aspx?eventID=' + data;
window.location.href = url;
}
当我将鼠标悬停在网址上时,它会显示我url =:
When I hover over url, it shows me url=:
/Admin/AddEvent.aspx?eventID=[Object Object]
如何让eventID显示实际值?
how can I get the eventID show the real value?
推荐答案
如果你没有选择使用服务器端编程,比如PHP,你可以使用查询字符串,或GET参数。
在表格中,添加方法=GET
If you have no option to use server-side programming, such as PHP, you could use the query string, or GET parameters.
In the form, add a method="GET"
<form action="display.html" method="GET">
<input type=""text"" name=""serialNumber"" />
<input type=""submit"" value=""Submit"" />
</form>
当他们提交此表单时,用户将被定向到包含serialNumber值作为参数的地址。类似的东西:
http://www.example.com/display.html?serialNumber=XYZ
您应该能够使用window.location.search值从JavaScript解析查询字符串 - 它将包含serialNumber参数值:
/ / from display.html
document.getElementById(write)。innerHTML = window.location.search; //你必须解析//查询字符串以提取你需要的//参数
When they submit this form, the user will be directed to an address which includes the serialNumber value as a parameter. Something like:
http://www.example.com/display.html?serialNumber=XYZ
You should then be able to parse the query string - which will contain the serialNumber parameter value - from JavaScript, using the window.location.search value:
// from display.html
document.getElementById("write").innerHTML = window.location.search; // you will have to parse // the query string to extract the // parameter you need
这篇关于将数据从1页传递到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!