Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*script dinamic003.js */
- jq112(function($) {/*tidak disarankan*/
- jq112(document).on({/*chShow*/
- click: function() {
- checkInfo( );
- if ($(this).is(":checked")){
- objDiv = $(this).parent().find("div");
- showLog( objDiv);
- objDiv.removeClass('hide');
- showLog("checked");
- }else{
- objDiv = $(this).parent().find("div");
- objInput = $(this).parent().find(".inpBobot");
- objInput.val(0);
- objDiv.addClass('hide');
- showLog("not checked");
- }
- }
- }, ".chShow");
- jq112(document).on({//.inpBobot
- change: function() {
- checkInfo(this);
- }
- }, ".inpBobot");
- });
- function checkInfo(obj){
- maxNum=100;
- numActive=0;
- jq112("#btnSimpan").removeClass("btnWarning");
- try {
- numChange= parseInt( jq112(obj).val() );
- }catch(err) {
- numChange =0;
- }
- iCheck=0;
- minCheck=3;
- maxCheck=5;
- jq112( ".inpBobot" ).each(function() {
- numActive += parseInt( jq112(this).val() );
- jq112(this).removeClass("redBorder");
- });
- jq112( ".chShow" ).each(function() {
- if (jq112(this).is(":checked")){
- iCheck++;
- }
- });
- if(iCheck < minCheck){
- nodeWrite("infoBobot", "Masukkan minimal "+minCheck+" input<br/>",1);
- jq112("#btnSimpan").addClass("btnWarning");
- }else if(iCheck > maxCheck){
- nodeWrite("infoBobot", "Masukkan maximal "+maxCheck+" input<br/>",1);
- jq112("#btnSimpan").addClass("btnWarning");
- }else{
- nodeWrite("infoBobot", "",1);
- }
- //nodeWrite("infoBobot", "Anda menginput:"+iCheck );
- if(numActive > maxNum){
- nodeWrite("infoBobot", "Nilai Bobot :"+numActive+"\nBatas Maximal:"+maxNum );
- nodeWrite("infoBobot", "<br/>silahkan di review kembali:"+ numInput);
- numInput = maxNum - (numActive - numChange);
- jq112(this).val( numInput ).addClass("redBorder");
- jq112("#btnSimpan").addClass("btnWarning");
- //alert("Nilai Bobot :"+numActive+"\nBatas Maximal:"+maxNum);
- }else if(numActive < maxNum){
- nodeWrite("infoBobot", "Nilai Bobot terinput:"+numActive );
- numInput = maxNum - (numActive);
- if(numInput!=0){
- nodeWrite("infoBobot", "<br/>Bobot yang dapat di input:"+ numInput);
- }
- showLog([numActive,maxNum]);
- jq112("#btnSimpan").addClass("btnWarning");
- }else if(numActive < maxNum){
- nodeWrite("infoBobot", "<br/>Bobot dapat diproses" );
- }
- return ;
- }
- function showLog( objLog ){
- try {
- //console.log( objLog );
- }
- catch(err) {
- /*console.log not work here*/
- }
- return ;
- }//function showLog()
- function nodeWrite(objName, content, clean){
- let element = document.getElementById(objName);
- if(clean){
- while ( element.lastChild ) {
- element.removeChild( element.lastChild );
- }
- }
- element.insertAdjacentHTML( "beforeend", content );
- return ;
- }
Advertisement
Add Comment
Please, Sign In to add comment