javascript - 使用 JavaScript 将另一个 HTML 文件形式的数据写入一个 HTML 文件
问题描述
我有两个文件:upload.html
和data.html
upload.html
有这种形式:
<form class="subir_py" type="POST">
<div class="row">
<div class="col-md-12">
<div class="titlepage">
<h2>Datos</h2>
</div>
<div class="col-md-12">
<input
class="contactus"
placeholder="Name"
type="text"
id="name"
required
/>
</div>
<div class="col-md-12">
<textarea
class="textarea"
placeholder="Description"
type="text"
name="Message"
id="message"
></textarea>
</div>
<div>
<input
class="imagearea"
type="hidden"
name="MAX_FILE_SIZE"
value="4194304"
/>
<input type="file" />
</div>
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<button
id="btnUpload"
class="btnUpload"
type="button"
onclick="getData()"
>
Subir
</button>
</div>
</div>
</div>
</form>
如您所见,我有一些数据要在那里收集和一张图像。现在,我想在 data.html 中以 id 为“proyects”的 div 中写入以这种形式收集的数据
所以,我创建了app.js
:
function getData() {
const nombreProyecto = document.getElementById("name").value;
const nombreOrganizacion = document.getElementById("message").value;
}
function writeData() {
var newDivName = document.createElement("div");
newDivName.appendChild(document.createTextNode(proyectName));
document.getElementById("proyects").appendChild(proyectName);
}
问题是因为它们是不同的 html 文件,所以在文件中找不到名为“proyects”的 div data.html
。我尝试过使用 webpack,但是由于我已经完成了所有的 html 和 css,所以现在很难捆绑所有内容。有谁知道另一种解决方案?
谢谢!
解决方案
推荐阅读
- cucumber - 如何在同一个项目中有多个 Cucumber 步骤定义来测试产品变体
- regex - 正则表达式 - 仅匹配带有特定单词的字符串
- python - Python:绘制按月归一化的直方图
- javascript - 如何选择元素的第一个类名?
- java - 为什么 request.getParameter("") 使用 jquery formdata 返回 null
- php - 如何创建一个以 php 变量命名的 mysql 表?
- javascript - 使用 jquery 设置会话 - ajax,php 不起作用
- java - Java Grid Layout错误的按钮大小和错误的位置
- android - 如何在 Whatsapp 中将文本设置为描述(关于)?
- javascript - 如何在使用 JavaScript 加载页面后自动触发“ESC”键