gpt4 book ai didi

javascript - HTML 多页表单显示隐藏部分保留表单数据

转载 作者:行者123 更新时间:2023-11-28 08:18:20 25 4
gpt4 key购买 nike

这是我的问题,我想要一个大约 25 页的表单,所以我想避免让一个巨大的页面永远滚动。

理想情况下,我希望在运行时加载外部 html 文件,同时保留表单数据直到用户提交它。

当用户点击一个链接时,我制作了一个带有漂亮酷菜单的初始页面, 我想用另一个 html 文件中的内容替换内容。

我尝试使用 javascript 函数并用 iframe 替换,但它并没有完全按照我想要的方式工作。通过足够的调试,我可以让它工作,但似乎必须有更好的方法来解决这个问题......

因为有时看起来很困难的问题有时用另一种方法会容易得多,所以请赐教。

function ContentMap()
{
var __contentMap = [];
var __index = 0;
this.length = function()
{
return __contentMap.length;
}
this.addContentMap = function(htmlContent)
{
__contentMap.push(htmlContent);
__index++;
console.log(htmlContent["id"]);
}
this.getContentMap = function(contentId)
{
for(q=0;q<__contentMap.length;q++)
{
if(contentId.localeCompare(__contentMap[q].id)==0)
{
return _contentMap[q];
}
}
}
this.getPreviousMap = function()
{
if(this.length()>0&&index>0)
{
index--;
return _contentMap[index];
}
else
{
return null;
}
}
}
var contentMap = new ContentMap();
function replaceContent(contentId,replacementId)
{
citem = document.getElementById(contentId);
for(__i=0;__i<citem.childNodes.length;__i++)
{
contentMap.addContentMap(citem.childNodes.item(__i));
citem.removeChild(citem.childNodes.item(__i));
}
iframe = document.createElement("IFRAME");
iframe.setAttribute("src",replacementId);
iframe.style.width = document.getElementById(contentId).width;
iframe.style.height = document.getElementById(contentId).height;
citem.appendChild(iframe);
}

最佳答案

i am not sure whether this is the solution you need. 

form1.php
<html>
<body>
<form action="#" method="post">
This is first form..
<input type="submit" name="form_2" value="submit form1">
<?php
if(isset($_POST['form_2'])) {
include("form2.html");
}
?>
</form>
</body>
</html>

form2.php

<html>
This is second form.
</html>

这将在同一页面上显示第二个表单,但您必须使用 css 以仅显示 form2

关于javascript - HTML 多页表单显示隐藏部分保留表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28877476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com