document.title = 'Open University Profile'; function gotoUrl(path, params, method) { method = method || "post"; var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); form.setAttribute("target","_self"); if (typeof params === 'string') { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", 'data'); hiddenField.setAttribute("value", params); form.appendChild(hiddenField); } else { for (var key in params) { if (params.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); if(typeof params[key] === 'object'){ hiddenField.setAttribute("value", JSON.stringify(params[key])); } else{ hiddenField.setAttribute("value", params[key]); } form.appendChild(hiddenField); } } } document.body.appendChild(form); form.submit(); } function validateInfo() { var valid = true; if ( $('#studentNamecopy').val() == '' || $('#studentNamecopy').val() == null || $('#studentNamecopy').val() == undefined ) { $('#studentNamecopy').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#studentNamecopy').css({'background-color': 'transparent', 'color': '#555'}); } if ( $('#fatherNamecopy').val() == '' || $('#fatherNamecopy').val() == null || $('#fatherNamecopy').val() == undefined ) { $('#fatherNamecopy').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#fatherNamecopy').css({'background-color': 'transparent', 'color': '#555'}); } if ( $('#motherNamecopy').val() == '' || $('#motherNamecopy').val() == null || $('#motherNamecopy').val() == undefined ) { $('#motherNamecopy').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#motherNamecopy').css({'background-color': 'transparent', 'color': '#555'}); } if ( $('#dateOfBirthcopy').val() == '' || $('#dateOfBirthcopy').val() == null || $('#dateOfBirthcopy').val() == undefined ) { $('#dateOfBirthcopy').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#dateOfBirthcopy').css({'background-color': 'transparent', 'color': '#555'}); } if ( $('#gendercopy').val() == '' || $('#gendercopy').val() == null || $('#gendercopy').val() == undefined || $('#gendercopy').val() == 'first_option' ) { $('#gender').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#gender').css({'background-color': 'transparent', 'color': '#555'}); } if ( $('#sscStandardPassYearcopy').val() == '' || $('#sscStandardPassYearcopy').val() == null || $('#sscStandardPassYearcopy').val() == undefined || $('#sscStandardPassYearcopy').val() == 'first_option' ) { $('#sscStandardPassYear').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#sscStandardPassYear').css({'background-color': 'transparent', 'color': '#555'}); } if ( $('#sscStandardExmGroupcopy').val() == '' || $('#sscStandardExmGroupcopy').val() == null || $('#sscStandardExmGroupcopy').val() == undefined || $('#sscStandardExmGroupcopy').val() == 'first_option' ) { $('#sscStandardExmGroup').css({'background-color': '#FFCECE', 'color': 'black'}); valid = false; } else { $('#sscStandardExmGroup').css({'background-color': 'transparent', 'color': '#555'}); } var MyRows = $('#aLevelTable').find('tbody').find('tr'); // console.log(MyRows.length); var aLvSubjects = parseInt(MyRows.length) - 1; if (aLvSubjects < 2) { alert("Please Select At Least Two Subjects from Higher Secondary Standard Examination in Open University"); } var stat = 0; var code; for (var i = 0; i < MyRows.length; i++) { if ($(MyRows[i]).find('td:eq(1) select').length > 0) { if ($(MyRows[i]).find('td:eq(1) select').val() == null || $(MyRows[i]).find('td:eq(1) select').val() == "" || $(MyRows[i]).find('td:eq(1) select').val() == undefined || $(MyRows[i]).find('td:eq(1) select').val() == "first_option") { $(MyRows[i]).find('td:eq(1) select').css('background-color', '#FFCECE'); valid = false; } else { $(MyRows[i]).find('td:eq(1) select').css('background-color', 'transparent'); } } if($(MyRows[i]).find('td:eq(2) select').length > 0) { if($(MyRows[i]).find('td:eq(2) select').val() == null || $(MyRows[i]).find('td:eq(2) select').val() == "" || $(MyRows[i]).find('td:eq(2) select').val() == undefined || $(MyRows[i]).find('td:eq(2) select').val() == "first_option") { $(MyRows[i]).find('td:eq(2) select').css('background-color', '#FFCECE'); valid = false; } else { $(MyRows[i]).find('td:eq(2) select').css('background-color', 'transparent'); } } } var MyRows2 = $('#oLevelTable').find('tbody').find('tr'); // console.log(MyRows2.length); var oLvSubjects = parseInt(MyRows2.length) - 1; if (oLvSubjects < 5) { alert("Please Select At Least Five Subjects from Secondary Standard Examination in Open University"); } var stat2 = 0; var code2; for (var i2 = 0; i2 < MyRows2.length; i2++) { if($(MyRows2[i2]).find('td:eq(1) select').length > 0) { if($(MyRows2[i2]).find('td:eq(1) select').val() == null || $(MyRows2[i2]).find('td:eq(1) select').val() == "" || $(MyRows2[i2]).find('td:eq(1) select').val() == undefined || $(MyRows2[i2]).find('td:eq(1) select').val() == "first_option") { $(MyRows2[i2]).find('td:eq(1) select').css('background-color', '#FFCECE'); valid = false; } else { $(MyRows2[i2]).find('td:eq(1) select').css('background-color', 'transparent'); } } if($(MyRows2[i2]).find('td:eq(2) select').length > 0) { if($(MyRows2[i2]).find('td:eq(2) select').val() == null || $(MyRows2[i2]).find('td:eq(2) select').val() == "" || $(MyRows2[i2]).find('td:eq(2) select').val() == undefined || $(MyRows2[i2]).find('td:eq(2) select').val() == "first_option") { $(MyRows2[i2]).find('td:eq(2) select').css('background-color', '#FFCECE'); valid = false; } else { $(MyRows2[i2]).find('td:eq(2) select').css('background-color', 'transparent'); } } } var fileSelect = 0; var fileSize = 0; $('.addFileUpBtn1').each(function(i, obj) { var id = $(this).attr('id'); // console.log(id); if( $('#'+id).get(0).files.length == 0 ) { $('#'+id).css('background-color', '#FFCECE'); valid = false; fileSelect = 1; } else { $('#'+id).css('background-color', 'transparent'); if( parseInt($('#'+id).get(0).files[0].size) > 250000 ) { $('#'+id).css('background-color', '#FFCECE'); // alert("File Size Can not Exceed 250 Kb"); valid = false; fileSize = 1; } else { $('#'+id).css('background-color', 'transparent'); } } }); $('.addFileUpBtn2').each(function(i, obj) { var id = $(this).attr('id'); // console.log(id); if( $('#'+id).get(0).files.length == 0 ) { $('#'+id).css('background-color', '#FFCECE'); valid = false; fileSelect = 1; } else { $('#'+id).css('background-color', 'transparent'); if( parseInt($('#'+id).get(0).files[0].size) > 250000 ) { $('#'+id).css('background-color', '#FFCECE'); // alert("File Size Can not Exceed 250 Kb"); valid = false; fileSize = 1; } else { $('#'+id).css('background-color', 'transparent'); } } }); $('.addFileUpBtn3').each(function(i, obj) { var id = $(this).attr('id'); // console.log(id); if( $('#'+id).get(0).files.length == 0 ) { $('#'+id).css('background-color', '#FFCECE'); valid = false; fileSelect = 1; } else { $('#'+id).css('background-color', 'transparent'); if( parseInt($('#'+id).get(0).files[0].size) > 250000 ) { $('#'+id).css('background-color', '#FFCECE'); // alert("File Size Can not Exceed 250 Kb"); valid = false; fileSize = 1; } else { $('#'+id).css('background-color', 'transparent'); } } }); if (fileSelect == 1) { alert("Select Necessary Files"); } if (fileSize == 1) { alert("File Size Can not Exceed 250 Kb"); } return valid; } $('body').on('click', '#registerBtn', function(e) { var dataStr = ''; var str = window.location.href; var res = str.split("/"); var url = res[0]+'//'+res[2]+'/'+res[3]; e.preventDefault(); var validate = validateInfo(); // alert(validate); if(validate == true) { var conf = confirm("Are You Sure to Do This?"); if (conf == true) { /* var dataStr = 'Hello'; var str = window.location.href; var res = str.split("/"); var url = res[0]+'//'+res[2]+'/'+res[3]; var fd = new FormData($(this).parents('form')[0]); console.log(fd); $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/aoLevelInfoWithFileUploadUtils/infoWFileUpload', type: "POST", data: fd, contentType: false, cache: false, processData:false, success: function(data) { console.log("Hey"); }, error: function(e) { } }); */ // first portion var eqid = $('#eqid').val(); var name = $('#studentNamecopy').val(); var father = $('#fatherNamecopy').val(); var mother = $('#motherNamecopy').val(); var gender = $('#gendercopy').val(); var olevelPassYr = $('#olevelPassYearcopy').val(); var dateofbirth = $('#dateOfBirthcopy').val(); var myDate = '15-07-2011'; var chunks = dateofbirth.split('/'); var formattedDate = chunks[2] + chunks[1] + chunks[0]; // first portion // second portion // a level string starts var hsdetails = ''; var alevelStr = ''; var MyRows = $('#aLevelTable').find('tbody').find('tr'); // console.log(MyRows.length); var subjectCode = ''; var letterGrade = ''; var subjectName = ''; for (var i = 0; i < MyRows.length; i++) { subjectCode = $(MyRows[i]).find('td:eq(1) select option:selected').val(); letterGrade = $(MyRows[i]).find('td:eq(2) select option:selected').text(); subjectName = $(MyRows[i]).find('td:eq(1) select option:selected').text(); if (i == 1) { alevelStr += subjectCode.trim()+':'+letterGrade.trim()+':'+subjectName.trim(); } else if (i > 1) { alevelStr += ', ' + subjectCode.trim()+':'+letterGrade.trim()+':'+subjectName.trim(); } } hsdetails += '0OPEN0'+alevelStr+''; // a level string ends // o level string starts var ssdetails = ''; var olevelStr = ''; var MyRows2 = $('#oLevelTable').find('tbody').find('tr'); // console.log(MyRows2.length); var subjectCode2 = ''; var letterGrade2 = ''; var subjectName2 = ''; for (var i2 = 0; i2 < MyRows2.length; i2++) { subjectCode2 = $(MyRows2[i2]).find('td:eq(1) select option:selected').val(); letterGrade2 = $(MyRows2[i2]).find('td:eq(2) select option:selected').text(); subjectName2 = $(MyRows2[i2]).find('td:eq(1) select option:selected').text(); if (i2 == 1) { olevelStr += subjectCode2.trim()+':'+letterGrade2.trim()+':'+subjectName2.trim(); } else if (i2 > 1) { olevelStr += ', ' + subjectCode2.trim()+':'+letterGrade2.trim()+':'+subjectName2.trim(); } } ssdetails += '0OPEN'+$('#sscStandardPassYearcopy').val()+''+olevelStr+''; // o level string ends // second portion // submitappdata var appdataStr = ''+eqid+''+name+''+father+''+mother+''+formattedDate+''+gender+''+ssdetails+hsdetails+''; $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/equivProfileRegistrationUtils/stdProfileUpdate', type: 'POST', async: false, data: { dataStr : appdataStr }, success: function(data) { // console.log(data.trim()); var xml = data.trim(); xmlDoc = $.parseXML( xml ), $xml = $( xmlDoc ), $message = $xml.find( "message" ); $status = $xml.find( "status" ); console.log($message.text()); if ($status.text() == 'SUCCESS') { // third portion (file upload) var data = new FormData(); var totErroredFiles = 0; var totUploadedFiles = 0; var totExceptionFiles = 0; // passport/ brn related files $('.addFileUpBtn1').each(function(i, obj) { var id = $(this).attr('id'); var filedata = $('#'+id).prop('files')[0]; var eqid = $('#eqid').val(); var fname3 = filedata.name; var fname2 = fname3.replace('&', ' '); var fname = fname2.replace(/'/g, ' '); var fextensionName = filedata.type; var val = fextensionName; var fextension = val.substr(val.indexOf("/") + 1); var idNo = id.split("_").pop(); var fileDesc = 'Passport/BRN'; // static description will be saved here // console.log(fname + ', ' + fileDesc + ', ' + filedata); var reader = new FileReader(); reader.readAsDataURL(filedata); reader.onload = function () { var fileDataStr = reader.result; console.log(fname + ', ' + fileDesc + ', ' + fileDataStr ); var file_data = { 'eqid': eqid, 'fname': fname, 'fext' : fextension, 'fileDesc': fileDesc, 'filedata': fileDataStr, }; var formStr = JSON.stringify(file_data); $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/aoLevelInfoWithFileUploadUtils/infoWFileUpload', type: 'POST', async: false, data: { formStr : formStr }, success : function(text) { console.log(text); if(text.trim() == 'ERROR') { totErroredFiles += 1; } else if(text.trim() == 'SUCCESS') { totUploadedFiles += 1; } else { // alert(text); totExceptionFiles += 1; } }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); }; }); // passport/ brn related files // a level related files $('.addFileUpBtn2').each(function(i, obj) { var id = $(this).attr('id'); var filedata = $('#'+id).prop('files')[0]; var eqid = $('#eqid').val(); var fname3 = filedata.name; var fname2 = fname3.replace('&', ' '); var fname = fname2.replace(/'/g, ' '); var fextensionName = filedata.type; var val = fextensionName; var fextension = val.substr(val.indexOf("/") + 1); var idNo = id.split("_").pop(); var fileDesc = 'A Level Marksheet/Transcript'; // static description will be saved here // console.log(fname + ', ' + fileDesc + ', ' + filedata); var reader = new FileReader(); reader.readAsDataURL(filedata); reader.onload = function () { var fileDataStr = reader.result; console.log(fname + ', ' + fileDesc + ', ' + fileDataStr ); var file_data = { 'eqid': eqid, 'fname': fname, 'fext' : fextension, 'fileDesc': fileDesc, 'filedata': fileDataStr, }; var formStr = JSON.stringify(file_data); $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/aoLevelInfoWithFileUploadUtils/infoWFileUpload', type: 'POST', async: false, data: { formStr : formStr }, success: function(text) { console.log(text); if(text.trim() == 'ERROR') { totErroredFiles += 1; } else if(text.trim() == 'SUCCESS') { totUploadedFiles += 1; } else { // alert(text); totExceptionFiles += 1; } }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); }; }); // a level related files // o level related files $('.addFileUpBtn3').each(function(i, obj) { var id = $(this).attr('id'); var filedata = $('#'+id).prop('files')[0]; var eqid = $('#eqid').val(); var fname3 = filedata.name; var fname2 = fname3.replace('&', ' '); var fname = fname2.replace(/'/g, ' '); var fextensionName = filedata.type; var val = fextensionName; var fextension = val.substr(val.indexOf("/") + 1); var idNo = id.split("_").pop(); var fileDesc = 'o Level Marksheet/Transcript'; // static description will be saved here // console.log(fname + ', ' + fileDesc + ', ' + filedata); var reader = new FileReader(); reader.readAsDataURL(filedata); reader.onload = function () { var fileDataStr = reader.result; console.log(fname + ', ' + fileDesc + ', ' + fileDataStr ); var file_data = { 'eqid': eqid, 'fname': fname, 'fext' : fextension, 'fileDesc': fileDesc, 'filedata': fileDataStr, }; var formStr = JSON.stringify(file_data); $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/aoLevelInfoWithFileUploadUtils/infoWFileUpload', type: 'POST', async: false, data: { formStr : formStr }, success: function(text) { console.log(text); if(text.trim() == 'ERROR') { totErroredFiles += 1; } else if(text.trim() == 'SUCCESS') { totUploadedFiles += 1; } else { // alert(text); totExceptionFiles += 1; } }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); }; }); // o level related files // third portion (file upload) // if success then set session with registered status $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/equivProfileRegistrationUtils/sessionUpdate', type: 'POST', async: false, data: { eqid : $('#eqid').val() }, success: function(message) { gotoUrl(url+'/hguidgrerehfbhiehuihfhdiufhioauffiphihfsdfiopsadfpasfsd/'+$('#eqid').val(), {"eqid": $('#eqid').val(), "state": "REGISTERED"}); }, error: function(e) { alert("Redirect Error"); } }); } else { alert($message.text()); } }, error: function(e) { } }); // submitappdata } } }); $(document).on('click', '#addMoreFileBtn1', function(e) { e.preventDefault(); var valid = 0; $('.addFileUpBtn1').each(function(i, obj) { var id = $(this).attr('id'); // console.log(id); if( $('#'+id).get(0).files.length == 0 ) { valid = 1; alert("Please Select A File First"); } }); if (valid == 0) { var max = 0; $('.addFileUpBtn1').each(function() { // max = Math.max(this.id, max); max = this.id; }); console.log("Hello: " + max); var myString = max.split("_").pop(); var maxNo = parseInt(myString) + 1; var r = $('
'); //$("#fileUploadDiv").append(r); $('

').insertBefore('#addMoreFileBtn1'); } }); $(document).on('click', '#addMoreFileBtn2', function(e) { e.preventDefault(); var valid = 0; $('.addFileUpBtn2').each(function(i, obj) { var id = $(this).attr('id'); // console.log(id); if( $('#'+id).get(0).files.length == 0 ) { valid = 1; alert("Please Select A File First"); } }); if (valid == 0) { var max = 0; $('.addFileUpBtn2').each(function() { // max = Math.max(this.id, max); max = this.id; }); console.log("Hello: " + max); var myString = max.split("_").pop(); var maxNo = parseInt(myString) + 1; var r = $('
'); //$("#fileUploadDiv").append(r); $('

').insertBefore('#addMoreFileBtn2'); } }); $(document).on('click', '#addMoreFileBtn3', function(e) { e.preventDefault(); var valid = 0; $('.addFileUpBtn3').each(function(i, obj) { var id = $(this).attr('id'); console.log(id); if( $('#'+id).get(0).files.length == 0 ) { valid = 1; alert("Please Select A File First"); } }); if (valid == 0) { var max = 0; $('.addFileUpBtn3').each(function() { // max = Math.max(this.id, max); max = this.id; }); console.log("Hello: " + max); var myString = max.split("_").pop(); var maxNo = parseInt(myString) + 1; var r = $('
'); //$("#fileUploadDiv").append(r); $('

').insertBefore('#addMoreFileBtn3'); } }); // Common Functions Start Here var alv_subs = ''; alvSubjects = '';// for a level var olv_subs = ''; olvSubjects = '';// for o level function getSelectedSubjects(exmType, table, selector) { // console.log(exmType + ', ' + table + ', ' + selector); const subjects = []; var code = ''; var v_table = ''; if(exmType == 'OPENHSCALL') { v_table = '#aLevelTable'; } else if(exmType == 'OPENSSC') { v_table = '#oLevelTable'; } var MyRows = $(v_table).find('tbody').find('tr'); // console.log(table + ', ' + MyRows.length); for (var i = 1; i < MyRows.length; i++) { if( $(MyRows[i]).find('td:eq(1) select').length > 0 ) { // checking if disabled option selected if($(MyRows[i]).find('td:eq(1) select').val() == null || $(MyRows[i]).find('td:eq(1) select').val() == "" || $(MyRows[i]).find('td:eq(1) select').val() == undefined || $(MyRows[i]).find('td:eq(1) select').val() == "first_option") { // continue; } else { code = $(MyRows[i]).find('td:eq(1) select').val(); subjects.push(code); } } } return subjects; } function getAlvOlvSubjects(exmType, table, selector) // here capture two parameters so that only one function can be used to populate two dropdown of alevel and olevel { // console.log(exmType + ', ' + table + ', ' + selector); if (exmType == 'OPENHSCALL') { var dataStr = exmType; } else { var dataStr = 'OPENSSC'+$('#sscStandardExmGroupcopy').val() ; } var str = window.location.href; var res = str.split("/"); var url = res[0]+'//'+res[2]+'/'+res[3]; $.ajax({ url: url+'/98ecedda8f00c7989c44b6e3c34b7175/getEnglishMediumSubjects/collecEMSubjects', type: 'POST', async: false, data: { dataStr : dataStr }, success: function(data) { // console.log(data.trim()); var xml = data.trim(); xmlDoc = $.parseXML( xml ), $xml = $( xmlDoc ), $subject = $xml.find( "subjects" ).find( "subject" ); var length = $xml.find( "subjects" ).find( "subject" ).length; // console.log(length); if (parseInt(length) > 0) { if(exmType == 'OPENHSCALL') { alv_subs = ''; var subject = []; subject = getSelectedSubjects(exmType, table, selector); // console.log("A Level: " + subject ); var options = ''; } else if(exmType == 'OPENSSC') { olv_subs = ''; var subject = []; subject = getSelectedSubjects(exmType, table, selector); // console.log("O Level: " + subject ); var options = ''; } // alert("Hurrah"); $xml.find( "subjects" ).find( "subject" ).each(function () { // console.log( $(this).find("name").text() ); if($.inArray($(this).find("value").text(), subject) > -1) { // console.log("Eat Mullah"); } else { options += ''; } }); // console.log(options); } else { alert("No Subject Available"); } $(selector).html(options); } }); } // Common Functions End Here // A Level Functions Start Here $(document).on('click', '.alvGrade', function() { var grade = $("option:selected", this).val(); var gradePoint = ''; // console.log(grade); if (grade == '1') { gradePoint = 5; } else if (grade == '2') { gradePoint = 4; } else if (grade == '3') { gradePoint = 3.5; } else if (grade == '4') { gradePoint = 3; } else if (grade == '5') { gradePoint = 2; } else if (grade == '6') { gradePoint = 1; } else if (grade == '7') { gradePoint = 0; } $(this).closest('tr').find('.alvGrPnt').val(gradePoint); }); reOrderAlvTable = function() { var rowCount = parseInt($('#aLevelTable > tbody > tr').length) - 1; // console.log(rowCount); var sl = 0; $('#aLevelTable > tbody > tr').each(function() { // console.log(sl); $(this).find('.sl').html(sl); $(this).find('.alvSubj').attr("id", 'alvSubj'+sl); sl++; }); } $(document).on('click', '.removeAlvSubject', function() { $(this).parent().parent().remove(); reOrderAlvTable(); }); function insertAlvTableRow() { var rowCount = parseInt($('#aLevelTable > tbody > tr').length) - 1; rowCount++; // console.log(rowCount); // getAllRemaining Subject list, if remains 0 then don't append any row and show a message // var slctSubject = getSelectHtmlFromJson(subjectList); // exlcude already selected subjects from specific table var appendString = ''+rowCount+''; appendString += ''; appendString += ''; $('#aLevelTable > tbody:last-child').append(appendString); getAlvOlvSubjects('OPENHSCALL', '#aLevelTable', "#alvSubj"+rowCount); // here i have to pass all the currently apppended row's select ID in specific table as parameter and also alevel/olevel } $(document).on('click', '#addNewAlvSubject', function() { // first check if any unselected row is there in specific level type table var MyRows = $('#aLevelTable').find('tbody').find('tr'); // console.log(MyRows.length); var stat = 0; var code; for (var i = 0; i < MyRows.length; i++) { if($(MyRows[i]).find('td:eq(1) select').length > 0) { if($(MyRows[i]).find('td:eq(1) select').val() == null || $(MyRows[i]).find('td:eq(1) select').val() == "" || $(MyRows[i]).find('td:eq(1) select').val() == undefined || $(MyRows[i]).find('td:eq(1) select').val() == "first_option") { alert("First Select Subject in Higher Secondary Standard Examination List"); $(MyRows[i]).find('td:eq(1) select').css('background-color', '#FFCECE'); stat = 1; break; } else { $(MyRows[i]).find('td:eq(1) select').css('background-color', 'transparent'); } } } if (stat == 0) { insertAlvTableRow(); } //// }); // A Level Functions End Here // O Level Functions Start Here $(document).on('click', '.olvGrade', function() { var grade = $("option:selected", this).val(); var gradePoint = ''; // console.log(grade); if (grade == '1') { gradePoint = 5; } else if (grade == '2') { gradePoint = 4; } else if (grade == '3') { gradePoint = 3.5; } else if (grade == '4') { gradePoint = 3; } else if (grade == '5') { gradePoint = 2; } else if (grade == '6') { gradePoint = 1; } else if (grade == '7') { gradePoint = 0; } $(this).closest('tr').find('.olvGrPnt').val(gradePoint); }); reOrderOlvTable = function() { var rowCount = parseInt($('#oLevelTable > tbody > tr').length) - 1; // console.log(rowCount); var sl = 0; $('#oLevelTable > tbody > tr').each(function() { // console.log(sl); $(this).find('.sl').html(sl); $(this).find('.olvSubj').attr("id", 'olvSubj'+sl); sl++; }); } $(document).on('click', '.removeOlvSubject', function() { $(this).parent().parent().remove(); reOrderOlvTable(); }); function insertOlvTableRow() { var rowCount = parseInt($('#oLevelTable > tbody > tr').length) - 1; rowCount++; // console.log(rowCount); var appendString = ''+rowCount+''; appendString += ''; appendString += ''; appendString += ''; $('#oLevelTable > tbody:last-child').append(appendString); getAlvOlvSubjects('OPENSSC', '#oLevelTable', "#olvSubj"+rowCount); // here i have to pass all the currently apppended row's select ID in specific table as parameter and also alevel/olevel } $(document).on('click', '#addNewOlvSubject', function() { if ( $('#sscStandardExmGroupcopy').val() == '' || $('#sscStandardExmGroupcopy').val() == null || $('#sscStandardExmGroupcopy').val() == undefined || $('#sscStandardExmGroupcopy').val() == 'first_option' ) { $('#sscStandardExmGroup').css({'background-color': '#FFCECE', 'color': 'black'}); alert("First Select Your Secondary Exam Group"); } else { $('#sscStandardExmGroup').css({'background-color': 'transparent', 'color': '#555'}); // first check if any unselected row is there in specific level type table var MyRows = $('#oLevelTable').find('tbody').find('tr'); // console.log(MyRows.length); var stat = 0; var code; for (var i = 0; i < MyRows.length; i++) { if($(MyRows[i]).find('td:eq(1) select').length > 0) { if($(MyRows[i]).find('td:eq(1) select').val() == null || $(MyRows[i]).find('td:eq(1) select').val() == "" || $(MyRows[i]).find('td:eq(1) select').val() == undefined || $(MyRows[i]).find('td:eq(1) select').val() == "first_option") { alert("First Select Subject in Secondary Standard Examination List"); $(MyRows[i]).find('td:eq(1) select').css('background-color', '#FFCECE'); stat = 1; break; } else { $(MyRows[i]).find('td:eq(1) select').css('background-color', 'transparent'); } } } if (stat == 0) { insertOlvTableRow(); } } //// }); // O Level Functions End Here