【发布时间】:2020-07-20 10:40:51
【问题描述】:
我有一个带有表单的 php 文件**(index.php)**。我还有另一个带有显示数据的php文件**(template1.php)**,它在提交后从index.php填写表格后显示数据。 现在,template1.php 应该显示在 index.php 中,如果我输入 index.php 表单的输入字段,那么字段数据应该同时显示在 template1.php 中。 为此,我使用 iframe。但没有找到解决方案。
index.php 是:
<iframe src="templates/alltemplates/template1.php" height="200" width="300" id="myframe"></iframe>
<form id="submit_form" action="#" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6 mb-50">
<span class="input">
<label class="" for="cf-email" style="font-weight: 500;">Upload Logo </label>
<input class="input__field cf-validate" type="file" id="logo" name="logo" accept="image/png,image/jpeg" />
</span>
</div>
<div class="col-md-6 mb-50">
<span class="input">
<label class="" for="cf-email" style="font-weight: 500;">Business Speciality </label>
<input class="input__field cf-validate" type="text" id="business_title" name="business_title" maxlength="40" oninput="iframetype('business_title', business_title.value)" />
</span>
</div>
js 文件为:
function iframetype(id, value)
{
var iframe = document.getElementById("myframe");
var elmnt = iframe.contentWindow.document.getElementById(id);
var iframeid = $(elmnt).attr('id');
}
在 js 中,我得到了 iframe 标签的 id,但在 index.php 和 template1.php 中,id 是相同的。所以不需要从 template.php 中找到 id 我需要,当我在 index.php 中输入 ** Business Specialty field** 时,应该更改 template1.php 中 ID business_title 的标签。和图片上传一样。 我整天都在尝试酵母。但没有得到任何解决方案。请给我解决方案。
template1.php 是:
<div class="col-md-12 col-md-12 col-xs-12 backgroundf0f0f0 center170">
<div class="row">
<div class="logo col-md-8 col-sm-6 col-xs-12 offset-sm-3 offset-md-2">
<img src="../../uploads/logo/file.jpg from index.php" alt="Logo" width="100%" height="auto" />
</div>
<div class="col-md-12 col-sm-12 col-xs-12 businessheadlineblack pdt10">
<h3 id="business_title">data from index.php</h3>
</div>
【问题讨论】:
标签: javascript php jquery iframe