Hi
I have a list named "Assigning to Individual" which has a drop down 'Initial Training'
The values in the drop down are Immediate, Hire Date, Specific. There is another textbox Date
There is a listbox which contains ermployee name.
There is another list "Employees" which contains Employee name and Hire Date.
The scenario is when the user selects hire date in the drop down in "Assigning to Individual", and selects employee name from the listbox, then the text box should populate based on the Employees list.
I have got the code using drop down but I do not know how to get the listbox selected value. If somebody could show the changes required in my code
$(document).ready(function () {
var currentPage = decodeURIComponent(window.location.href.replace(/\+/g, " "));
var result = null;
if (currentPage.contains("Assigning to Individual")) {
var dropdown = $("select[title = 'Initial Training']");
var dropdownid = dropdown[0].id;
if (dropdown.length != 0) {
populateCourseAssignment(dropdown, dropdownid)
$('#' + dropdownid).change(function () {
onChangeValueDropDown(dropdownid);
});
}
}
});
function populateCourseAssignment(dropdown, dropdownid) {
//var dropdown = $("select[title = 'Course Name']");
if (dropdown.length != 0) {
var selectedtext = $('#' + dropdownid + ' option:selected').text();
if (selectedtext == "Hire Date")
result = getCourseAssignment("Initial Training", selectedtext);
fillValuesInCourseAssignment();
}
}
function fillValuesInCourseAssignment() {
$("input[title = 'Date']").val(result[0].Hire_x0020_Date);
// $("input[title = 'Instructor Name']").val(result[0].Instructor);
}
function onChangeValueDropDown(dropdownid) {
var currentvalue = $('#' + dropdownid + ' :selected').text();
{
if (currentvalue == "Hire Date")
//I need to add listbox selected value
result = getCourseAssignment("", currentvalue);
fillValuesInCourseAssignment();
}
}
function getCourseAssignment(whereColumnName, whereColumnValue) {
var CAMLQuery = '<Query><Where><Eq><FieldRef Name="' + whereColumnName + '" /><Value Type="Text">' + whereColumnValue + '</Value></Eq></Where></Query>';
// var CAMLQuery = '<Query><Where><Eq><FieldRef Name="' + whereColumnName + '" /><Value Type="Text">' + whereColumnValue + '</Value></Eq></Where></Query>';
var course;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Employee",
CAMLQuery: CAMLQuery,
CAMLViewFields: "",
completefunc: function (xData, Status) {
// $(xData.responseXML).SPFilterNode("z:row").each(function () {
// wizardId = getData($(this).attr("ows_" + returnColumnName));
// });
course = $(xData.responseXML).SPFilterNode("z:row").SPXmlToJson({
includeAllAttrs: true,
removeOws: true
});
}
});
return course;
}
No comments:
Post a Comment