4 Replies Latest reply on Sep 5, 2017 6:47 AM by weezerboy

    Cant get "selected" to work when looping through months and dates

    weezerboy Level 1

      I have this code that outputs select lists of months and select lists of the dates (1-31)

       

      The form loads OK and the months and dates are in the lists just fine.

       

      Capture.PNG

       

      But when I select a month and a date I want it to stay selected when I submit the form

       

      So if I choose May 5 and click submit

       

      I want it to look like this

      c2.PNG

       

      But no matter what I select it always ends up January and 1

       

      Here is the code

       

       

      <tr>

                  <th>Choose  Feed Date:</th>

                  <th align="left"> <select name="feed_date_m">

                      <cfloop index="m" from=1 to=12>

                        <option value="#m#" <cfif #form.feed_date_m# is "m">selected</cfif>>#monthasstring(m)#  </option>

                      </cfloop>

                    </select>

                    <select name="feed_date_d">

                      <cfloop index="d" from=1 to=31>

                        <option value="#d#">#d#  <cfif #feed_date_d# is "d">selected</cfif></option>

                      </cfloop>

                    </select></th>

                </tr>