Skip to main content
November 1, 2010
Question

ignore empty fields

  • November 1, 2010
  • 1 reply
  • 874 views

Hello, I built a dreamweaver coldfusion form that sends information via cfmail. My problem is that the form has several selections and many of them may not be selected.  I want to ignore the textboxes not selected when the form sends the emails because the email is too cluttered.  is there a way to do this.....thanks,   kevin

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    November 1, 2010

    Sure there is a way.

    If statements would probably do the job easily.  Just test for blank fields.  len(trim(form.field)) EQ 0 is the usual test.

    November 2, 2010

    Thanks ilssac for the quick reply......  the form fields are blank to begin with so If the form fields are left blank, for instance  say "qty_item_1" is left blank and  "qty_item_2" has a value of 3 when the form is submitted.   i get this in the email......

    Quantity item1:

    Quantity item2: 3

    The quantity is left out in "Quantity item1:" which i want but i still get the "Quantity item1:" and i dont want that........

    .......thanks, kevin

    my code below

    Dear #Trim(FORM.FirstName)#

    Thanks for Your Order!

    You submitted the following information:
    Quantity item 1: #Trim(FORM.qty_item_1)#
    Quantity item  2: #Trim(FORM.qty_item_2)#
    --TOTAL AMOUNT DUE-- #Trim(FORM.grandTotal)#

    ilssac
    Inspiring
    November 2, 2010

    aswrt wrote:

    Dear #Trim(FORM.FirstName)#

    Thanks for Your Order!

    You submitted the following information:
    <cfif len(trim(FORM.qty_item_1)) GT 0>Quantity item 1: #Trim(FORM.qty_item_1)#</cfif>
    Quantity item  2: #Trim(FORM.qty_item_2)#
    --TOTAL AMOUNT DUE-- #Trim(FORM.grandTotal)#

    That should result in something different.