- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我遇到了一个似乎无法解决的问题。
首先,我有一个由专业人士建立的网站,我们与那家公司不再有工作关系。我现在自己管理网站。我有能力,但我绝不是一名经验丰富的 Web 开发人员。
背景:我们有一个使用多页表单呈现给最终用户的应用程序。该表单分 7 个步骤显示,但全部都是从一个 php 文件完成的,使用(我认为)jquery/javascript 循环执行这些步骤,并验证一些字段。在最后一步中,会显示一个摘要供用户提交。这很好用。
以下是我认为是处理页面循环的相关 javascript:
<script>
$(function () {
window.confirmLeave = true;
$('.datefield').datepicker();
var cache = {}; // caching inputs for the visited steps
$("#appForm").bind("step_shown", function(event,data){
if(data.isLastStep){ // if this is the last step...then
$("#summaryContainer").empty(); // empty the container holding the
$.each(data.activatedSteps, function(i, id){ // for each of the activated steps...do
if(id === "summary") return; // if it is the summary page then just return
cache[id] = $("#" + id).find(".input"); // else, find the div:s with class="input" and cache them with a key equal to the current step id
cache[id].detach().appendTo('#summaryContainer').show().find(":input").removeAttr("disabled"); // detach the cached inputs and append them to the summary container, also show and enable them
});
}else if(data.previousStep === "summary"){ // if we are movin back from the summary page
$.each(cache, function(id, inputs){ // for each of the keys in the cache...do
var i = inputs.detach().appendTo("#" + id).find(":input"); // put the input divs back into their normal step
if(id === data.currentStep){ // (we are moving back from the summary page so...) if enable inputs on the current step
i.removeAttr("disabled");
}else{ // disable the inputs on the rest of the steps
i.attr("disabled","disabled");
}
});
cache = {}; // empty the cache again
}
});
</script>
我还包含了以下表单的 html:
<form name="appForm" id="appForm" action="submit-app-exec.php" method="post"
enctype="multipart/form-data" autocomplete="off" onSubmit="showProgressBar()">
<fieldset class="step" id="page_1">
<div class="input">
<?php include("add-company/step1.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="page_2">
<div class="input">
<?php include("add-company/step2.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="page_3">
<div class="input">
<?php include("add-company/step3.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="page_4">
<div class="input">
<?php include("add-company/step4.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="page_5">
<div class="input">
<?php include("add-company/step5.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="page_6">
<div class="input">
<?php include("add-company/step6.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="page_7">
<div class="input">
<?php include("add-company/step7.html"); ?>
</div>
</fieldset>
<fieldset class="step" id="summary" >
<span class="font_normal_07em_black">Summary page</span><br />
<p>Please verify your information below.</p>
<div id="summaryContainer"></div>
</fieldset>
<div id="wizardNavigation">
<button class="navigation_button" onclick="javascript:saveApp()">Save</button>
<input class="navigation_button" id="back" value="Back" type="reset" />
<input class="navigation_button" id="next" value="Next" type="submit" onclick="javascript:noSaveApp()" />
<div class="clearFix"></div>
</div>
加载页面时,每个字段集都有额外的类和样式属性:
class="step ui-formwizard-content ui-helper-reset ui-corner-all" style="display: none;"
过程中用firebug观察,看到display: none;与该字段集交互时循环并更改为“阻止”。
问题:我们没有以任何方式让用户保存进度并稍后完成。我现在正在尝试这样做。我已经成功创建了“保存”按钮,它触发了一个 javascript 来更改表单的操作,它将数据发布到一个新的 php 文件,该文件处理和处理 POST 数据到 MySQL 中。这是可行的,但是,POST 仅传递当前查看的字段集中的数据,而不是 POST 所有数据。而且我无法弄清楚如何确保所有表单数据都已发布。任何指导或建议都会有所帮助。谢谢。
编辑:
我能够通过以下方式加载正确的页面:
$(function(){ $('#appForm').formwizard('show','" . $row["current_step"] . "'); });
这会加载正确的页面。现在的问题是,最后一步是一个摘要页面,显示最终提交的所有输入元素。但是,它似乎只显示已查看页面中的元素,我很确定是数组“data.activatedSteps”决定了元素是否在最终摘要中显示。你的代码会比我的更好地解决这个问题吗?再次感谢您对此的帮助。 –
最佳答案
<input>
具有属性 'disable'
的对象不要在 post/get 中返回。
这是在您的问题中需要特别注意的 javascript。
if(id === data.currentStep){ // (we are moving back from the summary page so...) if enable inputs on the current step
i.removeAttr("disabled");
}else{ // disable the inputs on the rest of the steps
i.attr("disabled","disabled");
}
这就是以前的编码员控制用户可以编辑的内容的方式。如果您希望在用户首先点击您的保存按钮时发送回所有值
removeAttr("disabled");
从页面上的所有内容然后提交帖子/获取。
看起来以前的编码人员通过遍历页面上的所有数据并在此处不禁用它来完成此操作。
if(data.isLastStep){ // if this is the last step...then
$("#summaryContainer").empty(); // empty the container holding the
$.each(data.activatedSteps, function(i, id){ // for each of the activated steps...do
if(id === "summary") return; // if it is the summary page then just return
cache[id] = $("#" + id).find(".input"); // else, find the div:s with class="input" and cache them with a key equal to the current step id
cache[id].detach().appendTo('#summaryContainer').show().find(":input").removeAttr("disabled"); // detach the cached inputs and append them to the summary container, also show and enable them
});
}
因此,您可以在发布返回时调用该代码,也可以执行类似的操作以启用页面上的输入。
根据您的评论,我建议使用它来解决您的问题,以便您始终使用相同的实用程序和库来操作页面上的对象。而且 JQuery 非常方便。
$(':input.ui-wizard-content').each(function() {$( this ).removeAttr("disabled");});
:input
获取页面上的所有输入。 .ui-wizard-content
告诉 JQuery 只查找具有该类的输入,然后是 .each
遍历每个对找到的对象运行 lambda 函数 ( function() {$( this ).removeAttr("disabled");}
) 的对象。
很难说是什么$row[]
在你的代码中。它显然是一个容器,但你提供的代码有点断章取义,所以我不能确定它是什么。
也就是说,如果我只有 DOM(页面上的内容的 Java 脚本表示)可以使用并且我知道您之前发布的功能,我会做这样的事情。
替换
if(data.isLastStep){ // if this is the last step...then
$("#summaryContainer").empty(); // empty the container holding the
$.each(data.activatedSteps, function(i, id){ // for each of the activated steps...do
if(id === "summary") return; // if it is the summary page then just return
cache[id] = $("#" + id).find(".input"); // else, find the div:s with class="input" and cache them with a key equal to the current step id
cache[id].detach().appendTo('#summaryContainer').show().find(":input").removeAttr("disabled"); // detach the cached inputs and append them to the summary container, also show and enable them
});
}
与
if(data.isLastStep){
$("#summaryContainer").empty();
$('.input :input').detach().appendTo('#summaryContainer').show().find(":input").removeAttr("disabled");
}
这主要是从以前的编码员所做的事情中借来的。他假设表格中的所有内容都在 data.activatedSteps
中。因为他创建的工作流程,但情况已不再如此。所以你要么需要看看他在哪里添加数据到data.activatedSteps
并在重新加载时以相同的方式将保存的内容放在那里。或者只使用忽略所有 data
的我的行东西,然后捕获每一个 <input>
在类 input
的对象中并将其添加到容器中。
注意:JQuery 的 $(TEXT)
使用与 CSS 相同的对象定义语法,并带有一些特别易于使用的插件,如“:input”。对我所说的内容有很好的引用here CSS 引用和 JQuery 特殊选择器语法检查 here .这就是我知道如何用非常紧凑的语句编写能够捕获您感兴趣的所有内容的方式。
关于javascript - 多页表单提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19365858/
扩展 SVG 标准以支持多个页面(又名 pageSet)的状态如何? 我看到几年前 SVG 1.2 和 SVG Print 计划慢慢停止,所以我想知道是否有人有关于 SVG future 功能的最新信
我是 PHP 的新手,在插入多个页面时使用 FPDI 有点困难。 我有一个包含 3 页的 .pdf 文件。我最终将第 1 页保存为第 3 页中的一个单独页面,并且与我的代码一起使用,但那是因为我的代码
有没有支持多页的 jQuery 画廊?我的问题是,每个页面包含不同数量的图像。我正在使用 Lightbox 2,但我看不到任何方法来配置多页画廊。我可以创建 5-6 个静态 HTML 页面,一页可以包
我正在开始使用 scrapy。我的 items.py 包含: class ParkerItem(scrapy.Item): account = scrapy.Field() m = s
我编写了一个代码来将单个 tiff 文件合并为多页 tiff。但输出最后带有空白页。如果输入文件是黑白的,但对于彩色的 .tiff 文件,代码工作正常。例如,如果我提供 100 个文件,作为输入输出,
我对 UIScrollView 中的 UITableView 有疑问。 情况是这样的: 我有一个 ListViewController,它在 UITableView 中显示一些事件。如果用户点击一个事
我想创建一个用于更改页面的按钮。我的问题是,我有一个我以前写的代码,但它不是我想要的那样工作。 代码如下: function loadingPage() { $(function () {
我希望对 1 个页面上的元素进行样式设置,并且不影响另一个页面上的相同元素。 我在每个元素上都有 class="homepage"。 有更好的方法吗? 为简单起见,这里是该页面上的 DIV。 h1.h
这是 jQuery 代码 $("#register-form").submit(function (e) { e.preventDefault(); }).validate({ rul
我的简单移动应用程序有 3 个页面,全部用 divs/data-role="page" 划分,并且位于同一文档 (.html) 中。页面加载完美,但如果我导航到第二页,按钮上的一个非常简单的单击事件将
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我是 python 新手。我目前正在研究网络抓取。任务是抓取戴尔社区 Inspiron 问题的前 5 页。我有运行并返回我需要的信息的代码。但是,我无法仅获取文本。我当前的代码返回文本 + html。
我目前正在为我已经完成的 m.file 开发一个 GUI。 GUI 将是一个具有多个页面的页面,每个页面都是一个独立的 GUI。 在主 GUI 上,用户将在具有 2 个选项的单选按钮组上进行选择。根据
我需要从我的程序中保存多页 TIFF,但它似乎是 Qt doesn't support multipage TIFF .尽管如此,我还是需要这样做。从我的程序开始执行此操作的最佳方法是什么? 到目前为
我遇到了尝试将几个多页 html 文件与 jquery mobile 链接的问题,发现使用 ajax 时,jquery mobile 不会显示完整文档,而是第一页。 我查找了问题并找到了 todd t
我是桌面应用程序开发的新手,有一个非常基本的问题。我有一个名为 MainWindow 的 WPF 窗体,我应该如何在上面设置多个页面,例如“用户管理”、“管理内容”等。 我想我有以下选择: 使用多种形
我看到了一些关于多页 tiff 的问题和一些关于压缩的问题,但没有(我看到的)将两者联系起来。 This question和我见过的一样近,让我非常接近,所以我希望如此。我进入了提到的 Oracle
我正在尝试建立一个简单的多页表单,使用 session 稍后存储在数据库中的多个表中。 然而,我似乎遇到了问题。虽然最后一页的值被发布到数据库,但 session 变量却没有。 请记住.. 我和我的项
我正在尝试构建一个多页面 Dash 应用程序。当我运行以下代码时,一切正常,除了它不会路由到我的/dash_1 或/dash_2 url。想知道是否有人可以帮助我。 我的结构是这样的: 破折号项目/
search_1=raw_input('search criteria 1? ') search_2=raw_input('search criteria 2? ') br = mechanize.B
我是一名优秀的程序员,十分优秀!