In JS file the following entry will be present where in the radio button value is obtained and set them as parameter value
$("button#checkdetail").click(function(e) {
var selectedVal=$("input[name='detaildata']:checked").val();
$("#detail-form").attr("action", "/<application-name>/show-detail/{"+ selectedVal+"}");
$( "#search-form").submit();
});
In Spring Controller , the request mapping will have the path variable to obtain the data as follows
@RequestMapping(value = "/show-detail/{selectedVal}", method = RequestMethod.POST)
public String showDetailPage(@PathVariable String selectedVal,
Model m, HttpServletRequest request) {
return "detail-page";
}
In Html Page
<form id="detail-form" name="detail-form">
<input type='radio' id='detaildata' name='detaildata' value='ByCar'/>
<input type='radio' id='detaildata' name='detaildata' value='ByVan'/>
<button type="submit" id="checkdetail" name="checkdetail" >Submit</button>
</form>
No comments:
Post a Comment