0
내 데이터베이스 (대기자 명단) 내의 항목 (사람) 수를 기반으로 예상 시간을 출력하려고합니다. 현재 이라는 빠른 형식으로 값을 저장합니다.이 값은 매번 1로 설정됩니다. countNumber = 1 (모두 포함) 인 모든 항목을 찾아서 모든 항목의 수를 구합니다. 그런 다음 getElementById()
을 사용하여 html을 업데이트 해보십시오.업데이트 html 유성?
내가 가지고있는 문제는 데이터베이스에 사람을 추가 할 때 예상 시간이 적절하게 올라갈 것이라는 점입니다. 그러나 페이지를 새로 고치면 HTML이 0으로 초기화됩니다.
페이지를 새로 고침해도 html이 항상 적절한 시간을 표시하도록 수정하려면 어떻게해야합니까?
HTML 코드 :
<head>
<title>Wait List</title>
</head>
<template name= "home">
<body>
<h2 id="insert">Approximate Wait Time: 0 Minutes</h2>
<div class="col-lg-6 col-lg-offset-3">
{{>quickForm id="studentForm" collection="Students" type="insert" template="bootstrap3-horizontal" label-class="col-sm-3" input-col-class="col-sm-9"}}
</div>
</body>
</template>
JS 코드 :
AutoForm.hooks({
studentForm:
{
onSuccess: function (insert,result) {
var totalCount = Students.find({countNumber:1}).count();
var waitTime = "Approximate Wait Time: " + totalCount*15 +" Minutes";
document.getElementById("insert").innerHTML = waitTime;
...
},
}
});