Reputation: 714
Hello I am trying to pass a variable who's value would come from a form input to a Query to retrieve a value and pass back to the form as a hidden value.Very confusing, and I hope I am overthinking this. I am getting a Passed_Lot_Number
is undefined error.
Here is the code I have so far:
<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>
Forgive me, this code is really old and I have been tasked to adding some more functionality to it. I really appreciate any help.
Thank you
Edit:
Here is some updated code:
<CFOUTPUT>
<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="/Buying/Shipping_Advice/Index.cfm" 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">
<cfif structKeyExists(form, "Passed_Lot_Number ")>
<cfquery name = "OutputDetails" datasource = "#Application.PrimaryDataSource#">
SELECT ShippingAdviceID
FROM tblShippingAdvice
WHERE CustomerID = #Passed_CustomerID#
AND LotNumber = #Passed_Lot_Number#
<cfreturn Passed_ShippingAdviceID />
</cfquery>
</cfif>
<input type="hidden" name="Passed_ShippingAdviceID" value="#Passed_ShippingAdviceID#">
</form>
</td>
</CFOUTPUT>
Upvotes: 0
Views: 2428
Reputation: 714
So I finally solved the issue. Turns out I was thinking about this wrong. Another perfect example of understanding data flow before working on something. Turns out there was a total of 3 pages that the data was passed through. It goes from Client -> Interface Page -> Display Results
. The form submitted to the Interface Page
and from there I just added logic that defined the Passed_ShippingAdviceID
variable. Here is the updated form code:
<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>
Here is the Query on the interface page that defined 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>
Upvotes: 1
Reputation: 482
First of all, you have checked this condition structKeyExists(form, "Passed_Lot_Number ")
. This means, after submitting the form, the inside of the condition code will be executed.
But, You have given code doesn't have to submit button. Please add the submit button.
After submitting the form, we can able to get the form fields value like as below,
form.Passed_CustomerID and form.Passed_Lot_Number
And you must to put the <cfreturn Passed_ShippingAdviceID />
code after the <cfquery>
tag.
I have added a code. Hope, this will help.
<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>
Thanks,
Upvotes: 0