gpt4 book ai didi

coldfusion - CFDIV 表单输入不发送表单字段

转载 作者:行者123 更新时间:2023-12-03 09:52:24 30 4
gpt4 key购买 nike

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

选择“工作”正常,因为您从第一个选择中选择了一个类别,它更改了第二个选择的值。但是spec_id不在表单post中。

这可能很简单。想法?

<!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>

最佳答案

你的 <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>

顺便说一句 - 不要使用 CFDIV 请参阅 https://github.com/cfjedimaster/ColdFusion-UI-the-Right-Way

关于coldfusion - CFDIV 表单输入不发送表单字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24663535/

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