Incorrect results in <cfloop>

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Incorrect results in <cfloop>

    Hi,

    I have 4 different dropdown of courses with courseID together with its data,
    PlayDate. Let say I have selected course 1, 2, 3 4 but when I insert in my DB I
    can?t insert the corresponding PlayDate and Number of players with its correct
    courseID I have selected. I have tried to use evaluate but still gives me
    error. Can anyone help me?

    <td>
    <select name="selectcourse" size="1" class="style5" id="selectcourse"
    onchange="javascript:copy()">
    <option value="" selected>-- Choose Alternate Course No. 1 --</option>
    <cfoutput query="getAlterNateCourses">
    <option value="#CourseID#">#name#</option>
    </cfoutput>
    </select>
    </td>
    <td>
    <td align="center" class="smv">
    <input type="text" name="PlayDAte" value="#PlayDate#" size="10"
    maxlength="12" class="smv">
    </td>
    <td align="center" class="smv">
    <input type="text" name="NumPlayers" value="#NumPlayers#" size="10"
    maxlength="12" class="smv">
    </td>


    <CFLOOP index="IDX" list="#Form.selectcourse#" delimiters=",">
    <cfquery name="InsertRound" datasource="#DSN#">
    INSERT INTO client_CourseCart(
    cartID,
    PlayDay,
    NumGolfers)
    VALUES (#courseID#,
    '#Evaluate("PlayDay_" & IDX)#,
    #Numplayers#
    PlayDay
    </cfquery>
    </ CFLOOP>

    Please advice how can I loop through my courseID with correct PlayDay and
    Number of Player I have provided.

    Thanks


    Eymard Guest

  2. Similar Questions and Discussions

    1. #40003 [NEW]: strtotime(), incorrect results
      From: matt at iws dot co dot nz Operating system: Linux 2.4 PHP version: 5.2.0 PHP Bug Type: Date/time related Bug...
    2. CFloop through Form results
      I'm trying to set a value of 1 or 0 if any Radio on a form submission (loop) is labeled 'OutofService'. The form is looped by Radio_ID. The...
    3. Collision modifier giving incorrect results?
      Does anyone know of any reason the Collision modifier would report a false collision on models, type #box, with scale different than vector(1,1,1)?
    4. Incorrect results on DB2 UDB v7.2
      Anyone recognised the following bug (is there an APAR)? Incorrect results can be returned when using IN lists of string literals and then...
    5. Re Incorrect results on DB2 UDB v7.2
      Further to previous post , please ignore - the following fixpak 8 APAR (originally for AIX) looks near-identical, certainly worth a shot: ...
  3. #2

    Default Re: Incorrect results in <cfloop>

    Hi,

    I assume I have not posted the right question here that is why I am not
    getting an answer?

    I would like to elaborate more on the above, I am trying to insert a record
    in my DB, I have four different pulldowns and a series of textboxes. Each
    pulldown i.e. CourseID has playdate, number of players. Now, for example I have
    selected pulldown number 2 with courseID 212 and enter PlayDate on and also
    number of players textboxes. I have again selected pulldown number 4 with
    courseID 215 and entered PlayDate and number of players.

    I press submit to insert the record in my DB but how can I evaluate my thoses
    elements that I have selected and entered in pulldown number 2 and pulldown
    number 4 and its suceeding row elements?

    I hope posted the right question.

    Thanks for the help.

    Eymard Guest

  4. #3

    Default Re: Incorrect results in <cfloop>

    I think the problem is that your question is not clear. Do you mean that you
    have multiple instances of the selectcourse input field in your form? As well
    as multiple PlayDate and NumPlayers fields? And you want to match them up?
    What I would do in a case like this is use a loop to generate a form with
    different field names. Then you would have: selectcourse1 PlayDate1
    NumPlayers1 selectcourse2 PlayDate2 NumPlayers2 etc. Then in your program
    that processes the form, you would loop again and insert the correct fields
    into your database: #Evaluate('Form.selectcourse' &amp; loopindex)#
    #Evaluate('Form.PlayDate' &amp; loopindex)# #Evaluate('Form.NumPlayers' &amp;
    loopindex)# Your example also has a JavaScript function set to an onchange
    event. Not sure what that does, but you shouldn't need it with this approach.
    -Paul Paul Dempsey Dickinson College

    dempster Guest

  5. #4

    Default Re: Incorrect results in <cfloop>

    Thank you very much for the input. Yes, I want to match up the form elements
    that I have filled in. But I have a dynamic pulldown for selectcourse listbox
    that changes when I selected different course.

    i.e.
    selectcourse1=212 PlayDay1212=03102005 NumberOfPlayers1212=4
    selectcourse2=234 PlayDay2234=03222005 NumberOfPlayers2234=2
    selectcourse3 PlayDay1 NumberOfPlayers3
    selectcourse4=126 PlayDay1126=03302005 NumberOfPlayers4126=4

    When I do a cfloop, I could not match the selected courseid with the
    succeeding form elements. I am not using the Javascript function now. I have
    tried it using javascript to create a dynamic formname elements to easily loop
    through it but has no luck.

    Any further explanations? Thanks again.

    Eymard 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