CFDIV表格输入不在帖子中发送表格

时间:2014-07-09 20:48:46

标签: coldfusion

我有一个简单的相关选择问题。我有一个cfdiv绑定到cfm与选择输入。

选择"工作"正确地说,您从第一个选择中选择一个类别,它会更改第二个选择的值。但spec_id不是邮件形式。

这可能很简单。想法?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>CFDiv Test</title>
</head>

<body>
<cfset application.dsn = "ASA">
<cfset session.event_id = 14>
<cfif isDefined('form.specSub')>
    <cfdump var="#form#"><cfabort>
</cfif>
<cfquery name="getSpecSets" datasource="#application.dsn#">
    SELECT S.Setup_ID, S.Setup_Name, S.Event_ID, is_Public, is_standard,
            (SELECT COUNT(Set_ID) FROM XR_Spec_Sets WHERE Setup_ID = S.Setup_ID) AS Spec_Count
    FROM Spec_Sets S
    WHERE S.Event_ID = 0
    OR S.Event_ID = <cfqueryparam value="#session.event_ID#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
<cfparam name="attributes.setup_id" default="#getSpecSets.setup_ID#">
<cfquery name="getEditName" datasource="#application.dsn#">
    SELECT Setup_Name FROM Spec_Sets WHERE Setup_id = <cfqueryparam value="#val(attributes.setup_ID)#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
<cfquery name="getSpecs" datasource="#application.dsn#">
    SELECT XR.*, S.Spec_Name, S.Spec_Cat, S.Event_ID
    FROM XR_Spec_Sets XR INNER JOIN Specs S ON XR.Spec_ID = S.Spec_ID
    WHERE XR.Set_ID = <cfqueryparam value="#val(attributes.setup_ID)#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
<cfquery name="getSpecCats" datasource="#application.dsn#">
    SELECT Distinct(Spec_Cat) AS Spec_Cat
    FROM Specs
    ORDER BY Spec_Cat DESC
</cfquery>
<script>
    function specSel(id) {
        url = "div_specs.cfm?spec_cat=" + id;
        ColdFusion.navigate(url,'spec_sel');
    }
</script>
<cfoutput>
<table width="95%" align="center" cellspacing="5" border="0">
    <tr>
        <td width="50%">
            <table cellpadding="3" width="100%" cellspacing="1" class="form">
                <tr><td colspan="7" class="page_subTitle">Spec Sets</td></tr>
                <tr>
                    <td class="grid_head">Set ID</td>
                    <td class="grid_head">Set Name</td>
                    <td class="grid_head">Event</td>
                    <td class="grid_head">Public</td>
                    <td class="grid_head">Standard</td>
                    <td class="grid_head" align="center">Edit</td>
                    <td class="grid_head" align="center">Delete</td>
                </tr>
                <form action="cfdivtest.cfm" method="post" name="specForm" id="specForm">
                <tr>
                    <td class="grid_row_alt" align="center">*</td>
                    <td class="grid_row_alt" align="center">
                        <input type="text" name="setup_name" size="25" maxlength="100" class="small">
                    </td>
                    <td class="grid_row_alt" align="center">
                        <select name="event_IDs" class="small">
                            <option value="0" SELECTED>All Events</option>
                            <option value="#session.event_ID#">This Event Only</option>
                        </select>
                    </td>
                    <td class="grid_row_alt" nowrap>
                        <input type="radio" name="is_Public" value="Yes"> Y<br>
                        <input type="radio" name="is_Public" value="No" checked> N
                    </td>
                    <td class="grid_row_alt" nowrap>
                        <input type="radio" name="is_standard" value="Yes"> Y<br>
                        <input type="radio" name="is_standard" value="No" checked> N
                    </td>
                    <td class="grid_row_alt" colspan="2" align="center"><input type="submit" name="addForm" value="Add >>" class="small"></td>
                </tr>
                </form>
                <cfloop query="getSpecSets">
                    <tr <cfif attributes.setup_id EQ getSpecSets.setup_id>style="font-weight:bold;"</cfif>>
                        <cfif getSpecSets.currentrow MOD 2 EQ 0><cfset class="grid_row_alt"><cfelse><cfset class="grid_row"></cfif>
                        <td class="#class#" align="center">#getSpecSets.setup_ID#</td>
                        <td class="#class#">#getSpecSets.Setup_Name#</td>
                        <td class="#class#"><cfif getSpecSets.event_id Eq 0>All Events<cfelse>This Event</cfif></td>
                        <td class="#class#" align="center">#getSpecSets.is_public#</td>
                        <td class="#class#" align="center">#getSpecSets.is_standard#</td>
                        <td class="#class#" align="center">
                        </td>
                        <td class="#class#" align="center">
                        </td>
                    </tr>
                </cfloop>
            </table>
        </td>
        <td width="50%">
            <table cellpadding="3" width="100%" cellspacing="1" class="form">
                <tr><td colspan="7" class="page_subTitle">Included Specs - #getEditName.setup_name#</td></tr>
                <tr>
                    <td class="grid_head" width="10%">&nbsp;</td>
                    <td class="grid_head" width="30%">Type</td>
                    <td class="grid_head" width="10%" align="center">Qty</td>
                    <td class="grid_head" width="30%">Spec</td>
                    <td class="grid_head" width="10%" align="center">Remove</td>
                </tr>
                <form action="cfdivtest.cfm?setup_ID=#attributes.setup_ID#" method="post" name="addForm" id="addForm">
            <tr>
                        <td class="grid_row_alt" align="center">*</td>
                        <td class="grid_row_alt" align="center">
                        <select name="spec_cat" onchange="specSel(this.value)" class="small">
                                <cfloop query="getSpecCats">
                                    <option value="#getSpecCats.spec_cat#" <cfif getSpecCats.currentrow EQ 1>SELECTED</cfif>>#getSpecCats.spec_cat#</option>
                                </cfloop>
                            </select>
                        </td>
                        <td class="grid_row_alt" align="center"><input type="text" name="qty" size="2" value="1" maxlength="6" class="small"></td>
                        <td class="grid_row_alt" align="center">
                            <cfdiv id="spec_sel" bind="url:div_specs.cfm?spec_cat=#getSpecCats.spec_cat[1]#"></cfdiv>
                        </td>
                        <td class="grid_row_alt" align="center" colspan="2"><input type="submit" name="specSub" class="small" value="Add >>"></td>
                    </tr>
                </form>
                <cfif getSpecs.recordcount>
                    <cfloop query="getSpecs">
                        <cfif getSpecs.currentrow MOD 2 EQ 0><cfset class="grid_row_alt"><cfelse><cfset class="grid_row"></cfif>
                        <tr>
                            <td class="#class#" align="right">#getSpecs.currentrow#.&nbsp;&nbsp;</td>
                            <td class="#class#">#getSpecs.spec_cat#</td>
                            <td class="#class#" align="center">#getSpecs.qty#</td>
                            <td class="#class#">#getSpecs.Spec_Name# (#getSpecs.event_id#)</td>
                            <td class="#class#" align="center">
                            </td>
                        </tr>
                    </cfloop>
                    <tr><td colspan="7" align="center">&nbsp;</td></tr>
                <cfelse>
                    <tr><td colspan="7" align="center"><strong><em>There are no specs assigned.</em></strong></td></tr>
                </cfif>
            </table>
        </td>
    </tr>
</table>
</cfoutput>
</body>
</html>

div_specs.cfm

<cfset application.dsn = "ASA">

<cfset session.event_id = 14>

<cfparam name="url.report" default="No">

<cfquery name="getSpecs" datasource="#application.dsn#">

    SELECT Spec_name AS Option_Text, Spec_ID AS Option_Value, Event_ID

    FROM Specs

    WHERE 1 = 1

    <cfif url.spec_cat NEQ "All">

        AND Spec_Cat = <cfqueryparam value="#url.spec_cat#" cfsqltype="CF_SQL_VARCHAR">

    </cfif>

    AND (Event_ID = 0 OR Event_ID = <cfqueryparam value="#session.event_ID#" cfsqltype="CF_SQL_INTEGER">)

    ORDER BY Spec_name

</cfquery>

<cfoutput>

<select name="spec_id" id="spec_id" class="small">

    <cfif url.report EQ "Yes">

        <option value="All" selected>All</option>

    </cfif>

    <cfloop query="getSpecs">

        <option value="#getSpecs.option_value#" <cfif getSpecs.currentrow EQ 1 AND url.report EQ "No">SELECTED</cfif>>

            #getSpecs.option_text#

        </option>

    </cfloop>

</select>

</cfoutput>

1 个答案:

答案 0 :(得分:3)

您的<form>无效地嵌套在</tr><tr>之间。将它移到<table>标记之外,它应该可以正常工作。

像这样:(为了清楚起见,请注意剥离)

<table width="95%" align="center" cellspacing="5" border="0">
<tr>
    <td width="50%">
        <form action="cfdivtest.cfm" method="post" name="specForm" id="specForm">
            <table cellpadding="3" width="100%" cellspacing="1" class="form">
                <tr><td colspan="7" class="page_subTitle">Spec Sets</td></tr>
                <tr>
                    <td class="grid_head">Set ID</td>
                    <td class="grid_head">Set Name</td>
                    <td class="grid_head">Event</td>
                    <td class="grid_head">Public</td>
                    <td class="grid_head">Standard</td>
                    <td class="grid_head" align="center">Edit</td>
                    <td class="grid_head" align="center">Delete</td>
                </tr>
                <tr>
                    <td class="grid_row_alt" align="center">*</td>
                    <td class="grid_row_alt" align="center">
                        <input type="text" name="setup_name" size="25" maxlength="100" class="small">
                    </td>
                    <td class="grid_row_alt" align="center">
                        <select name="event_IDs" class="small">
                            <option value="0" SELECTED>All Events</option>
                            <option value="#session.event_ID#">This Event Only</option>
                        </select>
                    </td>
                    <td class="grid_row_alt" nowrap>
                        <input type="radio" name="is_Public" value="Yes"> Y<br>
                        <input type="radio" name="is_Public" value="No" checked> N
                    </td>
                    <td class="grid_row_alt" nowrap>
                        <input type="radio" name="is_standard" value="Yes"> Y<br>
                        <input type="radio" name="is_standard" value="No" checked> N
                    </td>
                    <td class="grid_row_alt" colspan="2" align="center"><input type="submit" name="addForm" value="Add >>" class="small"></td>
                </tr>
            </table>
        </form>
    </td>
</tr>

BTW - 不要使用CFDIV 请参阅https://github.com/cfjedimaster/ColdFusion-UI-the-Right-Way