Adsense
Popular Posts
- Amazon web serive
- MySQL workbench -"Could not decrypt password cache"
- git svn conversion
- increase mysql query speed
- Unix Utils and wget in Windows
- add comment to table columns in phpMyAdmin
- Special characters pronunciation link
- deposit cheque in TD bank using Mobile phone
- Setup vi syntax for PHP
- Get WAMP running on EC2
Monday, August 31, 2015
jQuery, save old select value and restore in dropdown menu
Use following in click function
$(this).attr('oldValue',$(this).val());
to store old select value in dropdown menu
Restore later in change function
var oldValue = $(this).attr('oldValue');
More code
$('div.ajax_list td.TaList select').live('click', function(){
$(this).attr('oldValue',$(this).val());
});
$('div.ajax_list td.TaList select').live('change', function(){
var row = $(this).parent().parent();
var oldValue = $(this).attr('oldValue');
var worksheet = $('select#viewWorksheet').val();
var section = row.find('td.TutSection input').val();
var ta = row.find('td.TaList select').val();
var startTime = row.find('td.StartTime select.StartHour').val()+':'+row.find('td.StartTime select.StartMinute').val()+' '+row.find('td.StartTime select.StartPeriod').val();
var endTime = row.find('td.EndTime select.EndHour').val()+':'+row.find('td.EndTime select.EndMinute').val()+' '+row.find('td.EndTime select.EndPeriod').val();
var Day = row.find('td.Day select').val();
var Room = row.find('td.Room input').val();
var enrolMax = row.find('td.EnrolMax input').val();
var tutorialID = row.find('td input.tutorialID').val();
var course_id = row.find('td input.course_id').val();
var courses_offered_id = row.find('td input.courses_offered_id').val();
var status = row.find('td.Status select').val();
var type = row.find('td.type').html();
var assign_id =row.find('td input.assignedID').val();
var assign_id0 = 0;
if (assign_id == '' || assign_id == null || assign_id==0) {
// assign_id =0;
// var d = new Date();
// assign_id0 = d.valueOf();
// row.find('td input.assignedID').val(assign_id0);
row.find('td input').prop('disabled', true);
}
$.post('../_ajaxParts/TA/SITAAssignment.php',
{funct:'updateSITA',
tutorialID:tutorialID,
course_id:course_id,
courses_offered_id:courses_offered_id,
section:section,
ta:ta,
taprev:ta1,
type:type,
assign_id:assign_id,
assign_id0:assign_id0,
day:Day,
startTime:startTime,
endTime:endTime,
room:Room,
enrolMax:enrolMax,
status:status}, function(data){
formatJson(data,"div#notice", function(json){
row.find('td input').prop('disabled', false);
if(json.data['NotAllowed']==1) {
alert('LTD not allowed for SI assignment');
row.find('td.TaList select').val(oldValue);
}else if(json.data['NotAllowed']==2) {
alert('Adjunct appoinment not allowed for SI assignment');
row.find('td.TaList select').val(oldValue);
}else if(json.data['NotAllowed']==3) {
alert('The assignment is not allowed due to related contract blocked.');
row.find('td.TaList select').val(oldValue);
}
else {
if (json.data['lastid'] != '' && json.data['lastid'] != null && json.data['lastid']!=0 &&json.data['status']=='Insert')
row.find('td input.assignedID').val(json.data['lastid']);
if(json.data['success']==1)
formatJson('{"success":"SI\/TA Info Updated."}', "div#notice", null);
else
formatJson(json.data, "div#notice", null);
}
});
});
});
Subscribe to:
Posts (Atom)