【发布时间】:2019-03-02 10:48:06
【问题描述】:
我刚刚开始,我们学生和我创建了一个在线工作簿,但无法获得下载到文本文件的答案,它会下载,但是当我们打开文件时,它会出现 undefined 这是我的代码。
这适用于 Outlook,但学生没有 Outlook,他们有基于 Web 的 Office 365 电子邮件,我不允许使用我们的 smtp 服务器
电子邮件看起来像这样
姓名=此处显示的学生姓名
1.1= 答案显示在这里
1.2=
1.3=
1.4=
1.5=
1.6=
以此类推
这是我的代码示例
<form onsubmit="download(this['name'].value, ['text'].value, ['id'].value)">
<h4>Students Name<input type="text" name="Name" value="" size="50"><br></h4>
<br>
<h4>1. Why is it important to think about safety?</h4>
<p><label for="q1"><input type="radio" name="1.1" value=" A" id="q1a" />it identifies where the risks are.</label></p>
<p><label for="q1"><input type="radio" name="1.1" value=" B" id="q1b" />because I may get hurt.</label></p>
<p><label for="q1"><input type="radio" name="1.1" value=" C" id="q1c" />because it may prevent accidents and keep everyone safe.</label></p>
<p><label for="q1"><input type="radio" name="1.1" value=" D" id="q1d"/>because it will keep others safe.</label></p>
<br>
<h4>11. Respirators should be used to prevent?</h4>
<input type="text" name="1.11" id="1.11" size= "120"></p>
<br>
<h4>12. Disposable gloves are optional but do provide a convenient way to avoid?</h4>
<input type="text" name="1.12" id="1.12" size= "120"></p>
<br>
<h4>13. Why should you prevent liquid oil and grease from entering the pores of your skin?</h4>
<input type="text" name="1.13" id="1.13" size= "120"></p>
<br>
<h4>14. Why shouldn't we use hot water to wash off grease and oil off our hands?</h4>
<input type="text" name="1.14" id="1.14" size= "120"></p>
<br>
<h4>15. List 3 things that may cause a fire or act as a fuel?</h4>
<p>a. <input type="text" name="1.15a" id="1.15a" size= "117"></p>
<p>b. <input type="text" name="1.15b" id="1.15b" size= "117"></p>
<p>c. <input type="text" name="1.15c" id="1.15c" size= "117"></p>
<input type="submit" value="Download">
</style>
<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);
}
</script>
【问题讨论】:
-
谢谢,正如您从我的问题中看到的那样,我对编码真的很陌生。我的学生已经想出了安全网页,可以在学校内部使用,并希望将输入数据保存到文本文件中。 Outlook 位是我可以使用表单 method=post action=mailto 将其通过电子邮件发送到 Outlook,但我的学生没有 Outlook 访问权限,因此我们希望在他们的计算机上另存为可下载的文本文件。
-
这里有几个问题
1.应该使用呼吸器来预防?
2.一次性手套是可选的,但确实提供了一种方便的避免方式?
标签: html