pls me ,my problem using search in jsp application. search staff name . after filling these fields , controller search , results displayed on same page below search fields. problem want after submission , search values of search fields should remain on search form was.
i using :
<select name="requesttype" id="select" class="form-control" onchange="dropdownonchange(this);"> <option value=""><< select 1 >></option> <option value="all">all</option> <option value="staffname">staff name</option> <option value="leavetype">leave type</option> <option value="year">year</option> </select> <div class="col-sm-1"> <button type="submit" class="btn btn-primary">search</button> </div>
use javascript select search item once page loaded.
- at backend, receive search value name
requesttype, , when response, set value request, suchrequest.setattribute("requesttype", seachedvalue) - in jsp page, create input hidden next select element store requesttype response.
<input type="hidden" value="${requesttype}"/>. - at bottom of jsp page or use jquery ready function,
input[hidden]value, , use javascript select option.var searchtype = $('select[name="searchtype"]').next('input').value(); $('select[name="searchtype"] option').each(function(){ $(this).removeattr('selected'); if($(this).value() === searchtype) { $(this).attr('selected', 'selected'); } });
Comments
Post a Comment