0

I am trying to pass a form input to an external URL to be used somewhere else and perform a certain task. The issue I am having is actually getting the value and passing it. I either get a LotNumber is undefined or an error executing a Cfquery. I tried using CFPARAMhowever I think I misunderstand what cfparam does. Hopefully this is something simple.

Here is some code:

<table border="1" cellpadding="3" cellspacing="0" rules="GROUPS" frame="BOX" width="100%" bordercolor="#C0C0C0" bgcolor="#FFFFFF">
<thead>
<tr height="28">
    <td colspan="4"><b>Outstanding Shipping</b></td>
    <CFOUTPUT>
    <cfparam name="Show_SampleLogSheet.Passed_LotNumber" default="" />
    <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?Passed_CustomerID=#Passed_CustomerID#&Passed_ShippingAdviceID=#Get_ShippingAdvice.ShippingAdviceID#&Passed_Lot_Number=#Show_SampleLogSheet.Passed_LotNumber#&Passed_Activate=1" method="post" style="display: inline">
            <input type="hidden" name="Passed_CustomerID" value="#Passed_CustomerID#">
        <input class="frm3" type="text" name="Passed_LotNumber" value="#Show_SampleLogSheet.Passed_LotNumber#" size="3" maxlength="6" tabindex="25">
            </form>
        </td>
    </CFOUTPUT>

I really appreciate any help.

Thank you

Shawn
  • 4,758
  • 1
  • 20
  • 29
G.Rose
  • 644
  • 7
  • 29
  • 1
    1. What kind of a variable is `Show_SampleLogSheet`? Is it a query, struct, object? 2. Consider pushing all your variables over as hidden fields. 3. Use encodeForURL or encodeForHTMLAttribute on those variables. Who knows what they have in them. 4. OT: That is some old school HTML on the table there. Yet you are using CSS on other things. Consider 100% CSS – James A Mohler Sep 27 '18 at 14:26
  • The form name is `Show_SampleLogSheet`. 4. The code is ~5 years old, but I agree – G.Rose Sep 27 '18 at 14:30
  • How do you submit the form? – Shawn Sep 27 '18 at 16:43
  • Enter key and that submits the data to the url ideally – G.Rose Sep 27 '18 at 16:44
  • Funny thing is that I can use the `#Passed_LotNumber#` variable anywhere else. It's just that form – G.Rose Sep 27 '18 at 16:45
  • `Show_SampleLogSheet.Passed_LotNumber` doesn't refer to a `form` variable. Your `form` variable is only named `Passed_LotNumber`. Since you're using a `.` in your parameter name, CF may not be creating `Passed_LotNumber` where you think it is. Variables can get very strange when you use periods in the name. – Shawn Sep 27 '18 at 18:13

2 Answers2

1

For names are client side. ColdFusion does not need to name them at all. (Code has been somewhat similified

      <cfparam name="Passed_LotNumber" default="" />

I don't know what this field is good for. It is not within the form tag, so it is not going to get pushed over on submit.

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

Real form starts here. Note that passed_LotNumber does not need anything

      <form name="Show_SampleLogSheet" class="frm" action="/Buying/Shipping_Advice/Index.cfm?Passed_CustomerID=#Passed_CustomerID#&Passed_ShippingAdviceID=#Get_ShippingAdvice.ShippingAdviceID#&Passed_Lot_Number=#Passed_LotNumber#&Passed_Activate=1" method="post" style="display: inline">
      <input type="hidden" name="Passed_CustomerID" value="#Passed_CustomerID#">
      <input class="frm3" type="text" name="Passed_LotNumber" value="#Passed_LotNumber#" size="3" maxlength="6" tabindex="25">

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • Thanks, but didn't help. Still got the `Passed_LotNumber not defined` error and the parameter caused some other bugs in code – G.Rose Sep 27 '18 at 15:59
  • 1
    I just updated the answer. I see that you are pushing the save variable in two different ways. (A bad idea) – James A Mohler Sep 27 '18 at 16:22
  • Well I think I am going about this the wrong way. When you submit a form doesn't it send all of the input data to the action url? – G.Rose Sep 27 '18 at 16:36
  • 2
    Only the fields between the start of the
    tag and the end of the form tag are pushed. If you have your
    do a GET instead of POST, then everything that is a form field goes into the URL. That is a confusing road to go down. For your own sanity, I recommend always using POST and when in doubt, push a field via a hidden field and not over the URL. The reason for this is that you will want to process the data that being pushed over. Having everything in the `form.` scope is a good thing.
    – James A Mohler Sep 27 '18 at 16:45
  • 1
    @G.Rose- Though `cfparam` doesn't generally require scoping the variables, normally you should specify the expected variable scope (FORM scope when using "post", URL scope for "get"). Otherwise, CF picks up the first variable of that name it finds, which isn't always the correct one. That said, modifying legacy code doesn't to always allow for best practices. I once added cfparam scoping to a huge legacy app and instantly broke it because it turns out the app was passing variables with both POST and GET. – SOS Sep 27 '18 at 19:18
0

Turns out it was some the wrong input name. Here is the fixed 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="/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">
    </form>
</td>

There was a parameter that was hidden somewhere else named Passed_Lot_Number instead of Passed_LotNumber. I apologize, this is some super crap code and it's super old thus all of these dumb headaches. Thank you everyone

G.Rose
  • 644
  • 7
  • 29