将表单中的输入传递给Coldfusion查询

时间:2018-09-28 15:08:45

标签: javascript coldfusion coldfusion-2016

你好,我试图将一个变量的值从表单输入传递给查询,以检索一个值并将其作为隐藏值传递回表单。这非常令人困惑,我希望我对此有所考虑。我收到($exitCodes.psobject.Properties | Where-Object {$_.MemberType -eq 'NoteProperty'}).Name 是未定义的错误。

这是我到目前为止的代码:

Passed_Lot_Number

请原谅,这段代码确实很旧,我受命为它添加更多功能。非常感谢您的帮助。

谢谢

编辑:

这是一些更新的代码:

<CFOUTPUT>
    <cfquery name = "OutputDetails" datasource = "#Application.PrimaryDataSource#">
         SELECT ShippingAdviceID
         FROM ShippingAdvice
         WHERE CustomerID =  #Passed_CustomerID#
         AND LotNumber = #Passed_Lot_Number#
    </cfquery>
        <td align="left" colspan="1">
        <input class="frm3" type="text" id="Outstanding_Passed_LotNumber" size="3" maxlength="6" tabindex="25">
          <form name="Show_SampleLogSheet" class="frm" action="/Buying/Shipping_Advice/Index.cfm" method="post">
            <input type="hidden" name="Passed_CustomerID" value="#Passed_CustomerID#">
            <input class="frm3" type="text" name="Passed_Lot_Number" size="3" maxlength="6" tabindex="25">
          </form>
        </td>
</CFOUTPUT>

2 个答案:

答案 0 :(得分:1)

所以我终于解决了这个问题。原来我在想这个错误。在进行某些工作之前了解数据流的另一个完美示例。原来总共有3页数据通过。它来自Client -> Interface Page -> Display Results。提交给Interface Page的表单,然后我从那里添加了定义Passed_ShippingAdviceID变量的逻辑。这是更新后的表单代码:

<td align="left" colspan="1">
  <input class="frm3" type="text" id="Outstanding_Passed_LotNumber" size="3" maxlength="6" tabindex="25" style="background-color: ##838383;border:1px solid ##000000; color:white">
    <form name="Show_SampleLogSheet" class="frm" action="/Interface Page" method="post" style="display: inline">
      <input type="hidden" name="Passed_CustomerID" value="#Passed_CustomerID#">
      <input class="frm3" type="text" name="Passed_Lot_Number" size="3" maxlength="6" tabindex="25">
      <input type="hidden" value="1" name="Passed_Activate">
      <input type="hidden" value ="" name = "Passed_ShippingAdviceID">
    </form>
</td>

这是定义了Passed_ShippingAdviceID的界面页面上的查询:

<cfif Passed_ShippingAdviceID IS "">
  <cfquery name = "OutputDetails" datasource = "#Application.PrimaryDataSource#">
        SELECT ShippingAdviceID
        FROM tblShippingAdvice
        WHERE CustomerID =  '#Passed_CustomerID#'
        AND LotNumber = '#Passed_Lot_Number#'
  </cfquery>
    <cfset Passed_ShippingAdviceID = OutputDetails.ShippingAdviceID>
</cfif>

答案 1 :(得分:0)

首先,您已经检查了此条件structKeyExists(form, "Passed_Lot_Number ")。这意味着,提交表单后,条件代码的内部将被执行。

但是,您提供的代码不必提交按钮。请添加提交按钮。

提交表单后,我们可以获取如下所示的表单字段值,

form.Passed_CustomerID and form.Passed_Lot_Number

并且您必须将<cfreturn Passed_ShippingAdviceID />代码放在<cfquery>标记之后。

我添加了代码。希望这会有所帮助。

<cfoutput>
    <cfparam name="Passed_ShippingAdviceID" default="0">
    <cfif structKeyExists(form, "submit")>
        <cfquery name = "OutputDetails" datasource = "#Application.PrimaryDataSource#">
            SELECT ShippingAdviceID
            FROM tblShippingAdvice
            WHERE CustomerID =  "#form.Passed_CustomerID#"
            AND LotNumber = "#form.Passed_Lot_Number#"
        </cfquery>
        <cfset Passed_ShippingAdviceID = OutputDetails.ShippingAdviceID>
    </cfif>
    <form name="Show_SampleLogSheet" class="frm" action="/Buying/Shipping_Advice/Index.cfm" method="post" style="display: inline">
        <input class="frm3" type="text" id="Outstanding_Passed_LotNumber" size="3" maxlength="6" tabindex="25" style="background-color: ##838383;border:1px solid ##000000; color:white">
        <input type="hidden" name="Passed_CustomerID" value="#Passed_CustomerID#">
        <input class="frm3" type="text" name="Passed_Lot_Number" size="3" maxlength="6" tabindex="25">
        <input type="hidden" name="Passed_ShippingAdviceID" value="#Passed_ShippingAdviceID#">
        <input type="submit" value="submit" name="submit">
    </form>
</cfoutput>

谢谢