Files
ihrm/static/recruitment/candidate.js
Ashwanth Balakrishnan 58be33a8d7 Added Pre-Commit Hooks (#175)
* Added pre commit hook

* Run pre commit hook on all files

---------

Co-authored-by: Horilla <131998600+horilla-opensource@users.noreply.github.com>
2024-05-07 12:23:36 +05:30

49 lines
1.6 KiB
JavaScript

function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
$(document).ready(function () {
var stages = []
$('#recruitment').change(function (e) {
var recruitmentId = $(this).val()
if (recruitmentId) {
var a = $.ajax({
type: "post",
url: `/recruitment/recruitment-stage-get/${recruitmentId}/`,
data: {
'csrfmiddlewaretoken': getCookie('csrftoken'),
},
success: function (response) {
stages = JSON.parse(response['stages']);
let optionData = '';
for (let index = 0; index < stages.length; index++) {
const element = stages[index];
stage = element['fields']
if (element['pk']) {
optionData += `<option value="${element['pk']}">${stage['stage']}</option>`
}
}
$("#stage").html(optionData);
}
});
}
else{
$("#stage").html('');
}
});
});