-2

我真的可以在这方面使用一些帮助。我正在修改别人的代码。基本上该脚本所做的是它通过冷融合循环数据。假设用户将数据插入到这些循环项中的每一个中。然后一旦完成,就会弹出 javascript 框并确认用户输入的数据是正确的。这很好用......我遇到的问题是我需要在每个循环表单旁边有一个复选框,他们单击以选择他们要提交的循环表单。我已经让 Coldfusion 部分轻松工作。但是,我需要验证框来仅验证已检查的表格。

确认框变量示例

<cfset VARIABLES["PromptMessage" & CurrentRow] = VARIABLES["PromptMessage" & CurrentRow] & "<br /><br /><strong>LEASE:</strong>&nbsp;">
                    <cfset VARIABLES["PromptMessage" & CurrentRow] = VARIABLES["PromptMessage" & CurrentRow] & "L. HRS: <strong style=""color:black"">' + $('##LE_LEFH#CurrentRow#').val() + '</strong>">
                    <cfset VARIABLES["PromptMessage" & CurrentRow] = VARIABLES["PromptMessage" & CurrentRow] & "&nbsp;|&nbsp;L. CYCLES: <strong style=""color:black"">' + $('##LE_LCYCLES#CurrentRow#').val() + '</strong>">
                    <cfset VARIABLES["PromptMessage" & CurrentRow] = VARIABLES["PromptMessage" & CurrentRow] & "&nbsp;|&nbsp;R. HRS: <strong style=""color:black"">' + $('##LE_REFH#CurrentRow#').val() + '</strong>">
                    <cfset VARIABLES["PromptMessage" & CurrentRow] = VARIABLES["PromptMessage" & CurrentRow] & "&nbsp;|&nbsp;L. CYCLES: <strong style=""color:black"">' + $('##LE_RCYCLES#CurrentRow#').val() + '</strong>">
                    <cfset VARIABLES["PromptMessage" & CurrentRow] = VARIABLES["PromptMessage" & CurrentRow] & "<br /><br />">

复选框示例

<div style="color:##ff0000;background-color:;background-color:##dadada;border-left:1px solid ##999;border-right:1px solid ##999;border-bottom:1px solid ##999;"><input type="Checkbox" name="Confirm#CurrentRow#" value="1"> <strong>Select to report engine usage for this aircraft.</strong></div></div>

确认框操作代码。

 <script type="text/javascript">
    $(document).ready(function(){
      // catch submit 
      $("##btn_submit").click(function(e){
        jConfirm('<strong>Confirm your engine usage information. Click Confirm to proceed or Edit to edit your values.</strong><cfloop from="1" to="10" index="x">#VARIABLES["PromptMessage" & x]#</cfloop><br />', 'Report Confirmation Dialog', function(r) {
          // If they confirmed, manually trigger a form submission
          if (r) $("##btn_submit").parents("FORM").submit();
        });
        // Always return false here since we don't know what jConfirm is going to do
        return false;
      });
    });

$(document).ready(function() {
var $dialog = $('<div></div>')
    .html('This dialog will show every time!')
    .dialog({
        autoOpen: false,
        title: 'Basic Dialog',
        modal: true,
        height: 400,
        buttons: {
            "Delete all items": function() {
                $( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        }
    });

$('##popup').click(function() {
    $dialog.dialog('open');
    // prevent the default action, e.g., following a link
    return false;
});
});

 </script>

请记住,它是通过查询循环的。

4

1 回答 1

1

我建议你重新设计你的表格。与其将所有内容与查询的行号结合,不如将它们与记录的 id 字段结合。他们会更容易以这种方式工作。

如果复选框都具有相同的名称但不同的值,则它们将更容易使用。像这样的东西:

<cfoutput query="somequery">
<input type="checkbox" name="processme" value="#id#">
</cfoutput>

然后,当您处理表单时,您可以执行一个简单的循环。

<cfif StructKeyExists(form, "processme")>
<cfloop list = "#form.processme#" index="ThisID">
code
closing tags
于 2013-02-11T22:46:16.097 回答