Skip to main content
Known Participant
September 5, 2009
Question

Is <cfif structkeyexists(form, "btnSubmit")> throwing off my code ?

  • September 5, 2009
  • 1 reply
  • 1147 views

This is a report of a prior post but with a different question. I still cannot get it to work !

My form is basically a check box and a comments field. To delete the record, the checkbox must be checked and the comments entered :

<cfinput type="checkbox" name="del/#urdn_number#/#urdn_line_item#">

other fields here.....etc.
<cfinput type="text" name="comments/#urdn_number#/#urdn_line_item#" size="50" maxlength="50">

My submit button is :

The submit button is <input type="submit" name="btnSubmit">

When I submit the form to itself, I check to see if the submit button was selected or not by using

<cfif structkeyexists(form, "btnSubmit")>

The rest of the code :

<!--- Loop thru each checked box and extract the urdn number and Entry Item for that checked line --->
<cfloop index="i" list="#trim(form.fieldnames)#>

<cfif ListFirst(i, "/") is "comments">
  <cfset select_urdn_number = listgetat(i, 2, "/")>
  <cfset select_urdn_line_item = listlast(i, "/")>
  <cfset combineEnd = select_urdn_number & "/" & select_urdn_line_item>
   <cfif StructKeyExists(form, "del/" & combineEnd) and form["del/" & combineEnd] is "Yes">
    <cfset select_comments = form["comments/" & combineEnd]>

The record would be deleted here and the comments inserted into another table.

But it is not working, it appears the entire code fails due to the cfif ListFirst. This code works when it was in my action page and I did not have to

check to see if the submit button was selected. But now when I check for (form, btnSubmit), I think that is throwing off the code.

Can somebody please show this little girl how to correct this problem ? It is driving me nuts, works with action page and not when submits to itselft. I think it is a simple fix but I just cannot see it to get it to work.

The form variable btnSubmit does exists.

Thanks for any help.

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    September 7, 2009

    <cfloop index="i" list="#trim(form.fieldnames)#">

    Put the quotation mark at the end.