I want to read all the selected values in vertical way. Example for monday(09/24/2018) I have to read all select box value that would be in 1st loop. Next for Tuesday(09/25/2018) I have to read all select box value that would be in second loop.
<table class="myTable" id="rosterTable"> <col> <colgroup span="2"></colgroup> <colgroup span="2"></colgroup> <tr> <th colspan="1" scope="colgroup">Roster & Leave Details</th> <th colspan="1" scope="colgroup">Monday</th> <th colspan="1" scope="colgroup">Tuesday</th> <th colspan="1" scope="colgroup">Wednesday</th> <th colspan="1" scope="colgroup">Thursday</th> <th colspan="1" scope="colgroup">Friday</th> <th colspan="1" scope="colgroup" bgcolor="#feb236"><font color="#feb236">Saturday</font></th> <th colspan="1" scope="colgroup" bgcolor="#feb236"><font color="#feb236">Sunday</font></th> </tr> <tr> <th scope="col">${employees.currentWeek}'th-Week</th> <c:forEach items="${employees.days}" var="days"> <th id="dateDay" class="dateDay" scope="col">${days}</th> </c:forEach> </tr> <tr> <th># Name</th> <th>IST / Leave Details</th> <th>IST / Leave Details</th> <th>IST / Leave Details</th> <th>IST / Leave Details</th> <th>IST / Leave Details</th> <th>IST / Leave Details</th> <th>IST / Leave Details</th> </tr> <c:forEach items="${employees.listEmployee}" var="employee"> <tr> <th id="empName" class="empName" scope="row">${employee.firstName}${employee.lastName}</th> <td class="selectedShiftValue" id="monday"><select class="monday"> <option value="NONE"> --SELECT--<option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> <td class="selectedShiftValue" id="tuesday"><select class="tuesday"> <option value="NONE"> --SELECT--</option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> <td class="selectedShiftValue" id="wednesday"><select class="wednesday"> <option value="NONE"> --SELECT--</option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> <td class="selectedShiftValue" id="thursday"><select class="thursday"> <option value="NONE"> --SELECT--</option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> <td class="selectedShiftValue" id="friday"><select class="friday"> <option value="NONE"> --SELECT--</option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> <td class="selectedShiftValue" id="saturday"><select class="saturday"> <option value="NONE"> --SELECT--</option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> <td class="selectedShiftValue" id="sunday"><select class="sunday"> <option value="NONE"> --SELECT--</option> <c:forEach items="${employees.roster}" var="roster"> <option value="">${roster.shiftId} / ${roster.shiftValue}</option> </c:forEach> </select></td> </tr> </c:forEach> </table> The below code will take all employees in monday. For monday all the first select box values needs to pick.
$('#rosterTable .dateDay').each(function() { alert($(this).html()); $('#rosterTable .empName').each(function() { alert($(this).html()); // here monday all select box values needs to fetch. }); }); Any idea to get select box value in vertical manner.
Finally I need a json in below format.
{ "Object" : [ { "name":"GanesanSundareswaran", "date":"09/24/2018", "shiftDetails":" value selected from monday first select box towards the first name in the th section" }, { "name":"ArunRathesh", "date":"09/24/2018", "shiftDetails":" value selected from monday second select box towards the second name in the th section" }, { "name":"VishnuGopal", "date":"09/24/2018", "shiftDetails":" value selected from monday third select box towards the third name in the th section" } ] }
The name of the employee will be getting from db dynamically.
