javascript - How to pass hidden value from jQuery to Spring MVC controller without Ajax -


i have following table

    <table id="table">             <thead>             <tr>                 <th></th>                ...             </tr>             </thead>             <tbody>             <c:choose>                 <c:when test="${not empty userlist}">                     <c:foreach var="user" items="${userlist}">                         <tr>                             <td><input name="id" value="${user.id}" hidden></td>                             ...                         </tr>                     </c:foreach>                 </c:when>             </c:choose>             </tbody>         </table> <input type="button" name="objects"/> 

and here javascript select row in table

$(window).load(function () {     $("#table tr").click(function () {         $(this).addclass('selected').siblings().removeclass('selected');         var elem = $(this).find('td:first input').attr('value');     });      $('.objects').on('click', function (e) {         alert($("#table tr.selected td:first input").attr('value'));     }); }); 

when select row , press button objects alert of selected id. i'd pass id in spring mvc controller, desirable without ajax.

so want select user in table, press button objects , pass id of selected user new page /userobjects. can me this, please.

remove alert , :

var id = $("#table tr.selected td:first input").attr('value'); window.location = '/userobjects?id=' + id; 

you may have adapt window.location depending on url on want forward user.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -