所以我在javascript中做了一个快速而肮脏的日程安排,这里只会在本地内部网上使用。基本上,它有一堆可用的不同班次的单选按钮,当你单击提交时,它会保存到默认下载目录中的.txt文件。我需要的是能够限制每个班次最多110名员工,因为这是我们拥有的所有座位。有一个简单的方法来实现这个与JavaScript?或者我需要采用其他解决方案吗?提前致谢
<html>
<head>
<script language="Javascript" >
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' +
encodeURIComponent(text));
pom.setAttribute('download', filename);
pom.style.display = 'none';
document.body.appendChild(pom);
pom.click();
document.body.removeChild(pom);
}
function addTextTXT()
{
document.addtext.name.value = document.addtext.name.value + ".txt"
}
</script>
</head>
<body>
<form name="addtext" onsubmit="download(this['uid'].value, this['name'].value+this['m1'].value+this['m2'].value+this['tu1'].value+this['tu2'].value+this['w1'].value+this['w2'].value+this['th1'].value+this['th2'].value+this['f1'].value+this['f2'].value+this['sa1'].value+this['sa2'].value+this['su1'].value+this['su2'].value)" />
<P> Monday Tuesday Wednesday Thursday Friday Saturday Sunday
<br><input type="radio" name="m1" value=", m1 3-9," id="Monday1" />3-9   <input type="radio" name="tu1" value="tu1 3-9," id="Tuesday1" /> 3-9    <input type="radio" name="w1" value="w1 3-9," id="Wednesday1" />3-9    <input type="radio" name="th1" value="th1 3-9," id="Thursday1" />3-9   <input type="radio" name="f1" value="f1 3-9," id="Friday1" />3-9   <input type="radio" name="sa1" value="sa1 10-5," id="Saturday1" />10-5   <input type="radio" name="su1" value="su1 1-9," id="Sunday1" />1-9  
<br><input type="radio" name="m1" value="m1 5-9," id="Monday1" />5-9   <input type="radio" name="tu1" value="tu1 5-9," id="Tuesday1" /> 5-9    <input type="radio" name="w1" value="w1 5-9," id="Wednesday1" />5-9    <input type="radio" name="th1" value="th1 5-9," id="Thursday1" />5-9   <input type="radio" name="f1" value="f1 5-9," id="Friday1" />5-9
<br><input type="radio" checked="checked" name="m1" value="m1 Off," id="Monday1" />Off   <input type="radio" checked="checked" name="tu1" value="tu1 Off," id="Tuesday1" /> Off    <input type="radio" checked="checked" name="w1" value="w1 Off," id="Wednesday1" />Off    <input type="radio" checked="checked" name="th1" value="th1 Off," id="Thursday1" />Off   <input type="radio" checked="checked" name="f1" value="f1 Off," id="Friday1" />Off   <input type="radio" checked="checked" name="sa1" value="sa1 Off," id="Saturday1" />Off   <input type="radio" checked="checked" name="su1" value="su1 Off," id="Sunday1" />Off  
<br>
<P> Monday Tuesday Wednesday Thursday Friday Saturday Sunday
<br><input type="radio" name="m2" value="m2 3-9," id="Monday2" />3-9   <input type="radio" name="tu2" value="tu2 3-9," id="Tuesday2" /> 3-9    <input type="radio" name="w2" value="w2 3-9," id="Wednesday2" />3-9    <input type="radio" name="th2" value="th2 3-9," id="Thursday2" />3-9   <input type="radio" name="f2" value="f2 3-9," id="Friday2" />3-9   <input type="radio" name="sa2" value="sa2 10-5," id="Saturday2" />10-5   <input type="radio" name="su2" value="su2 1-9," id="Sunday2" />1-9  
<br><input type="radio" name="m2" value="m2 5-9," id="Monday2" />5-9   <input type="radio" name="tu2" value="tu2 5-9," id="Tuesday2" /> 5-9    <input type="radio" name="w2" value="w2 5-9," id="Wednesday2" />5-9    <input type="radio" name="th2" value="th2 5-9," id="Thursday2" />5-9   <input type="radio" name="f2" value="f2 5-9," id="Friday2" />5-9
<br><input type="radio" checked="checked" name="m2" value="m2 Off," id="Monday2" />Off   <input type="radio" checked="checked" name="tu2" value="tu2 Off," id="Tuesday2" /> Off    <input type="radio" checked="checked" name="w2" value="w2 Off," id="Wednesday2" />Off    <input type="radio" checked="checked" name="th2" value="th2 Off," id="Thursday2" />Off   <input type="radio" checked="checked" name="f2" value="f2 Off," id="Friday2" />Off   <input type="radio" checked="checked" name="sa2" value="sa2 Off," id="Saturday2" />Off   <input type="radio" checked="checked" name="su2" value="su2 Off" id="Sunday2" />Off  
<P><input type="text" name="uid" value="" placeholder="ID Number"><input type="text" name="name" value="" placeholder="Interviewer Name">
<input type="submit" onClick="addTexttxt();" value="Save As TXT">
</form>
</body>
</html>
答案 0 :(得分:1)
由于文件将存储在每个人的本地文件系统中,因此您的页面无法知道其他人的计算机的总数。您需要将文件/数据存储在服务器上,然后才能检查该单个文件(使用AJAX调用),然后新人才能注册轮班。
一个简单的服务器端语言是.php,大多数服务器已经支持或者你可以自己安装。