Create th:href based on values from javascript

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Create th:href based on values from javascript

David
This post was updated on .
Hi.
I'm using  this kind of button to redirect in my controller, and works ok.

<nabble_embed> <a class="btn btn-info" role="button" th:href="@{/grid/year/2017/month/12}"> <span th:text="#{grid}"></span> </a> </nabble_embed>

Well. I need  to change the values of year and month based on values selected in a javascript function like this:

$('#year').on('change', function() {
        var year = $(this).find('option:selected').val();
        var selectedYear= $(this).val();
});

so, if year selected is 2016 create a th:href="@{/grid/year/2016/month/12}

is this possible, or there is another option???
Thanks