我需要幫助在兩個aspx頁面之間傳遞數據(這些aspx頁面存儲在SharePoint Designer中)。我創建了一些JavaScript,可以對我們網站上的指標進行一些簡單的計算。使用javascript在兩個aspx頁面之間傳遞數據
https://tandemhospitalpartners.sharepoint.com/SitePages/Home.aspx
下面的JavaScript是在上面列出的ASPX鏈接。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
window.onload = function()
{
}
function p1()
{
totalPts = 137;
setTotalPts(totalPts);
divId = document.getElementById('avg'); // element represents the ID 'countdown' for the div
today = new Date(); //this represents todays date in the following format
//Weekday ex. "Tue"
//Month ex. "Aug"
//Todays Date ex. "08"
//Year ex. "2017"
//Time ex. "13:44:54 GMT - 0500 (Central Daylight Time"
svOpen = new Date(2017, 06, 17); // this represents the first day we accepted patients
one_day = 1000 * 60 * 60 * 24;
//milliseconds
//minutes
//seconds
//hours
//We have been open for 23 days
daysOpen = Math.ceil((today.getTime() - svOpen.getTime())/(one_day));
//subtracting SVNH open date from current date
avgPts = parseFloat(totalPts)/parseFloat(daysOpen);
divId.innerHTML ="Average Patients Per Day: "+ avgPts.toFixed(1);
}
function GetDays(element)
{
var el = document.getElementById(element);
today = new Date();
var cmas = new Date(today.getFullYear(), 6, 12);
if (today.getMonth() == 6 && today.getDate() > 13) {
cmas.setFullYear(cmas.getFullYear() + 1);
}
var one_day = 1000 * 60 * 60 * 24;
el.innerHTML =" Days to open the second Hospital: "+Math.ceil((cmas.getTime() - today.getTime())/(one_day));
}
function setTotalPts(totalPts)
{
totId = document.getElementById("leOne");
totId.innerHTML = "This is my total patients: " + totalPts.toString();
}
</script>
</head>
<body onload="p1(); GetDays('count'); setTotalPts();"+"text"> <!-- this onload is passing the div ID to the function p1(element)
element represents the ID -->
<div id='count' style="color: #e51400 ;
font-weight : 500;"></div>
</body>
<body>
<div id='avg' style="color: #e51400 ;
font-weight : 500;"></div>
</body>
<body>
<div id='leOne' style="color: #e51400 ;
font-weight : 500;"></div>
</body>
</html>
<!-- to keep a running count of the days i will have to subtract svOpen from todaysDate
我的目標是totalPts傳遞到HTML的ID是在不同的aspx文件。
這是包含我想要發送它的HTML ID的aspx文件的鏈接。
https://tandemhospitalpartners.sharepoint.com/ININD/SitePages/Home.aspx
這是我真的很困惑。我不知道如何實現這個結果。如果任何人有關於如何使用JavaScript可以完成的想法,我將不勝感激!
非常感謝你對你的迴應。如果你不介意,我仍然有幾個問題。我需要在第二頁上創建一個JavaScript函數嗎?我必須通過按鈕來做到這一點嗎?我必須在第一頁的JavaScript中創建一個getTotalPoints()方法嗎?從我的理解,它似乎像getTotalPoints()將是我的JS在第一頁上的方法,將有一個返回線,它返回我想要使用的變量? – hcienfue