mirror of
https://github.com/ae-utbm/sith.git
synced 2024-10-31 19:38:04 +00:00
pedagogy: auto fill search form from get arguments in URL
This commit is contained in:
parent
6f8ec4740c
commit
3063e4a24f
@ -48,6 +48,22 @@
|
||||
{% endfor %}
|
||||
|
||||
<script>
|
||||
|
||||
// Auto fill from get arguments
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
function autofillCheckboxRadio(name){
|
||||
if (urlParams.has(name)){ $("input[name='" + name + "']").each(function(){
|
||||
if ($(this).attr("value") == urlParams.get(name))
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (urlParams.has("search"))
|
||||
$("input[name='search']").first().prop("value", urlParams.get("search"));
|
||||
autofillCheckboxRadio("department");
|
||||
autofillCheckboxRadio("credit_type");
|
||||
autofillCheckboxRadio("semester");
|
||||
|
||||
// Allow unchecking a radio button when we click on it
|
||||
// Keep a state of what is checked
|
||||
var formStates = {};
|
||||
|
Loading…
Reference in New Issue
Block a user