By default, Jquery selects the first single vertex radio and the single vertex and jqueryradio with the specified value.
Overview when a page is loaded, the first option is selected for a single region in the specified region by default. When a user selects a single region and returns to the page again, you need to select the single-node JS selected last time and specify a radio with the id "admin-content-task"
// The value of the hidden field var platIdVal =$ ("# platIdVal "). val (); // if platIdVal is empty, it indicates that the single if (platIdVal = null | platIdVal = '') option is not checked '') {// the first $ (". admin-content-task input: first "). attr ("checked", true);} else {$ (". admin-content-task input [value = "+ platIdVal +"] "). attr ("checked", true );}
HTML page
<input type="hidden" id="platIdVal" value="${map.platIdVal?if_exists}"/>
<! -- Radio domain, some code --> <ul class = "am-list admin-content-task"> <# if apiInfos? Exists> <! -- N rows, using the chunk () function of FreeMarker --> <# list apiInfos? Chunk (7) as row> <div style = "clear: both; border: 0px solid green;"> <! -- Row number --> <div class = "platIdInnerDiv" style = "width: 1%;" >$ {row_index + 1}. </div> <! -- Div in the row, used to store the platId check box --> <# list row as obj> <div class = "platIdInnerDiv"> <input type = "radio" id = "platId $ {row_index }$ {obj_index} "name =" platId "value =" $ {obj. platId} "class =" platIdCls "/> <label for =" platId $ {row_index }$ {obj_index} ">$ {obj. platId} </label> </div> </# list> </# if> </ul>
Java
map.put("platIdVal", platId);
request.setAttribute("map", map);
UI
Original article, reprinted please indicate the source