CFIF Statement problems

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default CFIF Statement problems

    I am trying to write a cfif statement, which shows a form only if the statemnt
    acts true. It is a 3 part statement, the first two parts appear to work fine,
    but the final part does not. I only want the statement to be true if the
    Session.MM_Username is equal to the field task.allocation1. The code is as
    below hopefully someone can help me please!??? Thanks in advance <cfif
    (#task.completeown# EQ 1) AND (#task.completeass# EQ 0) AND
    (#Session.MM_username# EQ #task.allocation1#)> <form method='post' name='form3'
    action='<cfoutput>#CurrentPage#</cfoutput>'> <h5><font face='Arial, Helvetica,
    sans-serif'> Click here to confirm task as complete:</font></h5> <table
    align='center'><tr valign='baseline'><td nowrap align='right'>&amp;nbsp;</td>
    <td><input type='submit' value='Task Complete'></td> </tr> </table> <input
    type='hidden' name='MM_UpdateRecord' value='form3'> <input type='hidden'
    name='tasknum' value='<cfoutput>#task.tasknum#</cfoutput>'> <input
    type='hidden' name='completeass' value='1' <cfif (#task.completeass# EQ
    1)>checked</cfif>> </form></cfif>:beer;

    ford007 Guest

  2. Similar Questions and Discussions

    1. Repeating output with cfif statement
      I have a problem when multiple checkboxes are "turned on' when multiple values exist for a field in a database. For example: The following code...
    2. Help with cfif statement
      Can anyone help me find the correct way to write the following statement? <cfif form.user2 NEQ 15 or 50 or 51 or 52 or 53 or 55 or 200 or 223 or...
    3. Dymanic Query and CFIF Problems
      Problem: I have an application where I have one access table with the following fields: autonum, cca_index, cca_category, wt_index, wt_category. ...
    4. Login error with CFIF statement
      Hi all: I'm having trouble with a login CFIF routine. The following code works fine when the login is TRUE, but when I try to login with invalid...
    5. Using cfoutput within a cfif statement
      I am trying to setup a form validation, what i need to do is look at the Specimen Number entered and compare it against the database to see if it...
  3. #2

    Default Re: CFIF Statement problems

    First off, you can simplify your CFIF statement - see below. That probably
    doesn't solve your problem, but it makes your code more readable.



    <cfif task.completeown EQ 1 AND ask.completeass EQ 0 ANDSession.MM_username EQ
    task.allocation1>

    jdeline Guest

  4. #3

    Default Re: CFIF Statement problems

    > First off, you can simplify your CFIF statement - see below. That probably
    > doesn't solve your problem, but it makes your code more readable.
    >
    > <cfif task.completeown EQ 1 AND ask.completeass EQ 0 ANDSession.MM_username EQ
    > task.allocation1>
    And if task.completeown and ask.completeass are boolean values (ie: either
    1 or 0), you can further clarify this as:

    <cfif task.completeown AND NOT ask.completeass AND Session.MM_username EQ
    task.allocation1>

    But, back to the problem... you're finding that the Session.MM_username EQ
    task.allocation1 expression is returning false? Hmmm. This kinda suggests
    that they're not actually the same. You sure one of them doesn't have some
    whitespace around the value you're not noticing?

    It's also better to use compare() than EQ with strings, but it's not going
    to help your situation; just food for thought.

    Do this:

    <cfoutput>
    #task.completeown#<br />
    #NOT ask.completeass#<br />
    #Session.MM_username EQ task.allocation1#<br />
    </cfoutput>

    The should all be yes / not-zero / true.

    Are they?

    --

    Adam
    Adam Cameron Guest

  5. #4

    Default Re: CFIF Statement problems

    sorry bout the late reply, but i try not to work weekends. Err the answers to
    the query you asked me to run came out as follows 1 Yes No So it is looking
    as if you are correct, and my task.allocation1 and Session.MM_username are not
    matching. I will have a look into this. Thanks for your help so far will let
    you know how it goes, and if i run into further problems.

    ford007 Guest

  6. #5

    Default Re: CFIF Statement problems

    The following cannot work:
    <cfif (#task.completeown# EQ 1) AND (#task.completeass# EQ 0) AND
    (#Session.MM_username# EQ #task.allocation1#)>
    ...
    <cfif (#task.completeass# EQ 1)>checked</cfif>>
    </cfif>

    In order to enter the first cfif block #task.completeass# must be 0. How can
    it ever be 1 for the "check" value?
    What does checking a hidden field do anyway?


    OldCFer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139