vendredi 5 février 2016

Trying to pull table values from a selected check box correctly

I am trying to pull columns from a table if a checkbox was selected. Here is the table that contains the checkbox called 'selectedSched'

        <tbody style="overflow-y: scroll; ">
                    <c:forEach  var="row" items="${Updresults}">
                    <c:set var="sched" value="${row.getSCHEDULE_NUMBER()}" />
                    <c:set var="eftyear" value="${row.getEFT_CONTRACT_YEAR()}" />
                    <c:set var="EFTstatus" value="${row.getSTATUS()}" />
                    <c:set var="schedcombo"  value="${sched}${eftyear}" />
                    <fmt:formatNumber var="schedTotl" value="${row.getTOTAL_AMOUNT()}" pattern="$##,###,##0.00"/>
                    <tr>
                        <td align="center">  
                           <input style="width:50px;" type="checkbox" name="selectedSched"   
                                  value="<c:out value="${schedcombo}"/>"/>  
                        </td> 

                       <td id="ModifyScheduleNumber"><c:out value="${row.getSCHEDULE_NUMBER()}" /></td>
                       <td id="ModifyYear"><c:out value="${row.getEFT_CONTRACT_YEAR()}" /></td>
                       <td id="ModifyCreationDate"><c:out value="${row.getCREATION_DATE()}"/></td>
                       <td style="text-align: right; padding-right: 5px;"><c:out value="${row.getNUM_OF_PAY_RECORDS()}"/></td>
                       <td style="text-align: right; padding-right: 5px;"><c:out value="${schedTotl}"/></td>
                       <td><select style="width:45px;" size="1" id="ModifyStatus" name="ModifyStatus_<c:out value="${schedcombo}"/>" 
                                   class="combosmall">
                           <c:forEach items="${ModifyList}" var="statusValue">
                              <option value="${statusValue}"
                                <c:if test="${EFTstatus} = statusValue"> selected="selected"</c:if>
                                 >${statusValue}</option>
                           </c:forEach>
                       </select> </td>
                       <td>
                         <input style="width:85px" id="ModifyStatusDate" name="ModifyStatusDate_<c:out value="${schedcombo}"/>" 
                                type="text" class="texttable" value="${row.getSTATUS_DATE()}"/>
                       </td>
                       <td><c:out value="${row.getAPPR_HUD_EMPLOYEE()}"/></td>
                    </tr>
                    </c:forEach>

                   </tbody>

I am creating a function that is trying to compare the Creation date field to an input Status Date field. Here is my function call:

        $("#submitMEFTS").mouseup(function ()
                    {

                        for(var i=0; i<updateformID.selectedSched.length; i++)
                         {
                  if(updateformID.selectedSched[i].checked == true)
                              { 
                                var holdCreationDate = $('#ModifyCreationDate[i]').val();
                                var holdSchedule = $('#ModifyScheduleNumber[i]').val();
                                alert("The checked button was clicked");

                  } 
                              else
                              {
                                  alert("The checked button was not clicked") ;
                              }
                          }
                     });  

I have the selected check working but I am getting an error trying to use the 'ModifyCreationDate' field. Clearly just putting a '[i]' at the end is invalid. What is the proper way to pull the correct index of this field?

I know with a servlet call I had to do something similar to the ModifyStatus field to create different "names" for each row but wondering if there is a better/cleaner option.

Thanks again




Aucun commentaire:

Enregistrer un commentaire