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

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

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -