javascript - Prevent Incrementing until ui Slider val > 200 -


i have taken script net , need little push understand how achieve following:

  1. commission should begin increment after #yw0 val > 200.
  2. when under 200 commission stay 0 credit amount change normal.
  3. also reason if change comission 0 total still 51.6 , dont know why?

current code:

jquery(function($) {    jquery('#yw0').slider({      'range': 'max',      'min': 0,      'max': 130,      'slide': function(event, ui) {          $("#credit_amount").val(ui.value);          $("#amountsdiv").text(getamount(ui.value));          generateadditionalprecents(ui.value);          refreshvalues();          if (parseint($("#amountsdiv").text()) > "200") {          $('#t2').removeclass('not-active');        } else {          $('#t2').addclass('not-active');        };        },      'value': 0    });      jquery('#yw1').slider({      'range': 'max',      'min': 0,      'max': 5,      'slide': function(event, ui) {        $("#credit_duration").val(ui.value);        $("#durationdiv").text(getduration(ui.value));        refreshvalues();      },      'value': 0    });  });      function getamount(id) {    var amounts = new array("50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100", "105", "110", "115", "120", "125", "130", "135", "140", "145", "150", "155", "160", "165", "170", "175", "180", "185", "190", "195", "200", "205", "210", "215", "220", "225", "230", "235", "240", "245", "250", "255", "260", "265", "270", "275", "280", "285", "290", "295", "300", "305", "310", "315", "320", "325", "330", "335", "340", "345", "350", "355", "360", "365", "370", "375", "380", "385", "390", "395", "400", "405", "410", "415", "420", "425", "430", "435", "440", "445", "450", "455", "460", "465", "470", "475", "480", "485", "490", "495", "500", "505", "510", "515", "520", "525", "530", "535", "540", "545", "550", "555", "560", "565", "570", "575", "580", "585", "590", "595", "600", "605", "610", "615", "620", "625", "630", "635", "640", "645", "650", "655", "660", "665", "670", "675", "680", "685", "690", "695", "700");    return amounts[id];  }    function getduration(id) {    var durations = new array("5", "10", "15", "20", "25", "30");    return durations[id];  }        function refreshvalues() {    var amountsmatrix = new array();    amountsmatrix[0] = new array("1.6", "1.76", "1.92", "2.08", "2.24", "2.4", "2.56", "2.72", "2.88", "3.04", "3.2", "3.36", "3.52", "3.68", "3.84", "4", "4.16", "4.32", "4.48", "4.64", "4.8", "4.96", "5.12", "5.28", "5.44", "5.6", "5.76", "5.92", "6.08", "6.24", "6.4", "6.56", "6.72", "6.88", "7.04", "7.2", "7.36", "7.52", "7.68", "7.84", "8", "8.16", "8.32", "8.48", "8.64", "8.8", "8.96", "9.12", "9.28", "9.44", "9.6", "9.76", "9.92", "10.08", "10.24", "10.4", "10.56", "10.72", "10.88", "11.04", "11.2", "11.36", "11.52", "11.68", "11.84", "12", "12.16", "12.32", "12.48", "12.64", "12.8", "12.96", "13.12", "13.28", "13.44", "13.6", "13.76", "13.92", "14.08", "14.24", "14.4", "14.56", "14.72", "14.88", "15.04", "15.2", "15.36", "15.52", "15.68", "15.84", "16", "16.16", "16.32", "16.48", "16.64", "16.8", "16.96", "17.12", "17.28", "17.44", "17.6", "17.76", "17.92", "18.08", "18.24", "18.4", "18.56", "18.72", "18.88", "19.04", "19.2", "19.36", "19.52", "19.68", "19.84", "20", "20.16", "20.32", "20.48", "20.64", "20.8", "20.96", "21.12", "21.28", "21.44", "21.6", "21.76", "21.92", "22.08", "22.24", "22.4");    amountsmatrix[1] = new array("3.15", "3.46", "3.78", "4.09", "4.41", "4.72", "5.04", "5.35", "5.67", "5.98", "6.3", "6.61", "6.93", "7.24", "7.56", "7.87", "8.19", "8.5", "8.82", "9.13", "9.45", "9.76", "10.08", "10.39", "10.71", "11.02", "11.34", "11.65", "11.97", "12.28", "12.6", "12.91", "13.23", "13.54", "13.86", "14.17", "14.49", "14.8", "15.12", "15.43", "15.75", "16.06", "16.38", "16.69", "17.01", "17.32", "17.64", "17.95", "18.27", "18.58", "18.9", "19.21", "19.53", "19.84", "20.16", "20.47", "20.79", "21.1", "21.42", "21.73", "22.05", "22.36", "22.68", "22.99", "23.31", "23.62", "23.94", "24.25", "24.57", "24.88", "25.2", "25.51", "25.83", "26.14", "26.46", "26.77", "27.09", "27.4", "27.72", "28.03", "28.35", "28.66", "28.98", "29.29", "29.61", "29.92", "30.24", "30.55", "30.87", "31.18", "31.5", "31.81", "32.13", "32.44", "32.76", "33.07", "33.39", "33.7", "34.02", "34.33", "34.65", "34.96", "35.28", "35.59", "35.91", "36.22", "36.54", "36.85", "37.17", "37.48", "37.8", "38.11", "38.43", "38.74", "39.06", "39.37", "39.69", "40", "40.32", "40.63", "40.95", "41.26", "41.58", "41.89", "42.21", "42.52", "42.84", "43.15", "43.47", "43.78", "44.1");    amountsmatrix[2] = new array("4.75", "5.22", "5.7", "6.17", "6.65", "7.12", "7.6", "8.07", "8.55", "9.02", "9.5", "9.97", "10.45", "10.92", "11.4", "11.87", "12.35", "12.82", "13.3", "13.77", "14.25", "14.72", "15.2", "15.67", "16.15", "16.62", "17.1", "17.57", "18.05", "18.52", "19", "19.47", "19.95", "20.42", "20.9", "21.37", "21.85", "22.32", "22.8", "23.27", "23.75", "24.22", "24.7", "25.17", "25.65", "26.12", "26.6", "27.07", "27.55", "28.02", "28.5", "28.97", "29.45", "29.92", "30.4", "30.87", "31.35", "31.82", "32.3", "32.77", "33.25", "33.72", "34.2", "34.67", "35.15", "35.62", "36.1", "36.57", "37.05", "37.52", "38", "38.47", "38.95", "39.42", "39.9", "40.37", "40.85", "41.32", "41.8", "42.27", "42.75", "43.22", "43.7", "44.17", "44.65", "45.12", "45.6", "46.07", "46.55", "47.02", "47.5", "47.97", "48.45", "48.92", "49.4", "49.87", "50.35", "50.82", "51.3", "51.77", "52.25", "52.72", "53.2", "53.67", "54.15", "54.62", "55.1", "55.57", "56.05", "56.52", "57", "57.47", "57.95", "58.42", "58.9", "59.37", "59.85", "60.32", "60.8", "61.27", "61.75", "62.22", "62.7", "63.17", "63.65", "64.12", "64.6", "65.07", "65.55", "66.02", "66.5");    amountsmatrix[3] = new array("6.25", "6.87", "7.5", "8.12", "8.75", "9.37", "10", "10.62", "11.25", "11.87", "12.5", "13.12", "13.75", "14.37", "15", "15.62", "16.25", "16.87", "17.5", "18.12", "18.75", "19.37", "20", "20.62", "21.25", "21.87", "22.5", "23.12", "23.75", "24.37", "25", "25.62", "26.25", "26.87", "27.5", "28.12", "28.75", "29.37", "30", "30.62", "31.25", "31.87", "32.5", "33.12", "33.75", "34.37", "35", "35.62", "36.25", "36.87", "37.5", "38.12", "38.75", "39.37", "40", "40.62", "41.25", "41.87", "42.5", "43.12", "43.75", "44.37", "45", "45.62", "46.25", "46.87", "47.5", "48.12", "48.75", "49.37", "50", "50.62", "51.25", "51.87", "52.5", "53.12", "53.75", "54.37", "55", "55.62", "56.25", "56.87", "57.5", "58.12", "58.75", "59.37", "60", "60.62", "61.25", "61.87", "62.5", "63.12", "63.75", "64.37", "65", "65.62", "66.25", "66.87", "67.5", "68.12", "68.75", "69.37", "70", "70.62", "71.25", "71.87", "72.5", "73.12", "73.75", "74.37", "75", "75.62", "76.25", "76.87", "77.5", "78.12", "78.75", "79.37", "80", "80.62", "81.25", "81.87", "82.5", "83.12", "83.75", "84.37", "85", "85.62", "86.25", "86.87", "87.5");    amountsmatrix[4] = new array("8", "8.8", "9.6", "10.4", "11.2", "12", "12.8", "13.6", "14.4", "15.2", "16", "16.8", "17.6", "18.4", "19.2", "20", "20.8", "21.6", "22.4", "23.2", "24", "24.8", "25.6", "26.4", "27.2", "28", "28.8", "29.6", "30.4", "31.2", "32", "32.8", "33.6", "34.4", "35.2", "36", "36.8", "37.6", "38.4", "39.2", "40", "40.8", "41.6", "42.4", "43.2", "44", "44.8", "45.6", "46.4", "47.2", "48", "48.8", "49.6", "50.4", "51.2", "52", "52.8", "53.6", "54.4", "55.2", "56", "56.8", "57.6", "58.4", "59.2", "60", "60.8", "61.6", "62.4", "63.2", "64", "64.8", "65.6", "66.4", "67.2", "68", "68.8", "69.6", "70.4", "71.2", "72", "72.8", "73.6", "74.4", "75.2", "76", "76.8", "77.6", "78.4", "79.2", "80", "80.8", "81.6", "82.4", "83.2", "84", "84.8", "85.6", "86.4", "87.2", "88", "88.8", "89.6", "90.4", "91.2", "92", "92.8", "93.6", "94.4", "95.2", "96", "96.8", "97.6", "98.4", "99.2", "100", "100.8", "101.6", "102.4", "103.2", "104", "104.8", "105.6", "106.4", "107.2", "108", "108.8", "109.6", "110.4", "111.2", "112");    amountsmatrix[5] = new array("9.5", "10.45", "11.4", "12.35", "13.3", "14.25", "15.2", "16.15", "17.1", "18.05", "19", "19.95", "20.9", "21.85", "22.8", "23.75", "24.7", "25.65", "26.6", "27.55", "28.5", "29.45", "30.4", "31.35", "32.3", "33.25", "34.2", "35.15", "36.1", "37.05", "38", "38.95", "39.9", "40.85", "41.8", "42.75", "43.7", "44.65", "45.6", "46.55", "47.5", "48.45", "49.4", "50.35", "51.3", "52.25", "53.2", "54.15", "55.1", "56.05", "57", "57.95", "58.9", "59.85", "60.8", "61.75", "62.7", "63.65", "64.6", "65.55", "66.5", "67.45", "68.4", "69.35", "70.3", "71.25", "72.2", "73.15", "74.1", "75.05", "76", "76.95", "77.9", "78.85", "79.8", "80.75", "81.7", "82.65", "83.6", "84.55", "85.5", "86.45", "87.4", "88.35", "89.3", "90.25", "91.2", "92.15", "93.1", "94.05", "95", "95.95", "96.9", "97.85", "98.8", "99.75", "100.7", "101.65", "102.6", "103.55", "104.5", "105.45", "106.4", "107.35", "108.3", "109.25", "110.2", "111.15", "112.1", "113.05", "114", "114.95", "115.9", "116.85", "117.8", "118.75", "119.7", "120.65", "121.6", "122.55", "123.5", "124.45", "125.4", "126.35", "127.3", "128.25", "129.2", "130.15", "131.1", "132.05", "133");      $("#pricediv").text(amountsmatrix[$("#credit_duration").val()][$("#credit_amount").val()]);    $("#amount2div").text(getamount($("#credit_amount").val()));      $("#alldiv").text(number(getamount($("#credit_amount").val())) + number(amountsmatrix[$("#credit_duration").val()][$("#credit_amount").val()]));        = new date;      now.setdate(now.getdate() - 1 + number(getduration($("#credit_duration").val())));    }    function generateadditionalprecents(amount) {    var additionalamountsmatrix = new array();    additionalamountsmatrix[0] = new array("5", "5.5", "6", "6.5", "7", "7.5", "8", "8.5", "9", "9.5", "10", "10.5", "11", "11.5", "12", "12.5", "13", "13.5", "14", "14.5", "15", "15.5", "16", "16.5", "17", "17.5", "18", "18.5", "19", "19.5", "20", "20.5", "21", "21.5", "22", "22.5", "23", "23.5", "24", "24.5", "25", "25.5", "26", "26.5", "27", "27.5", "28", "28.5", "29", "29.5", "30", "30.5", "31", "31.5", "32", "32.5", "33", "33.5", "34", "34.5", "35", "35.5", "36", "36.5", "37", "37.5", "38", "38.5", "39", "39.5", "40", "40.5", "41", "41.5", "42", "42.5", "43", "43.5", "44", "44.5", "45", "45.5", "46", "46.5", "47", "47.5", "48", "48.5", "49", "49.5", "50", "50.5", "51", "51.5", "52", "52.5", "53", "53.5", "54", "54.5", "55", "55.5", "56", "56.5", "57", "57.5", "58", "58.5", "59", "59.5", "60", "60.5", "61", "61.5", "62", "62.5", "63", "63.5", "64", "64.5", "65", "65.5", "66", "66.5", "67", "67.5", "68", "68.5", "69", "69.5", "70");    additionalamountsmatrix[1] = new array("6", "6.6", "7.2", "7.8", "8.4", "9", "9.6", "10.2", "10.8", "11.4", "12", "12.6", "13.2", "13.8", "14.4", "15", "15.6", "16.2", "16.8", "17.4", "18", "18.6", "19.2", "19.8", "20.4", "21", "21.6", "22.2", "22.8", "23.4", "24", "24.6", "25.2", "25.8", "26.4", "27", "27.6", "28.2", "28.8", "29.4", "30", "30.6", "31.2", "31.8", "32.4", "33", "33.6", "34.2", "34.8", "35.4", "36", "36.6", "37.2", "37.8", "38.4", "39", "39.6", "40.2", "40.8", "41.4", "42", "42.6", "43.2", "43.8", "44.4", "45", "45.6", "46.2", "46.8", "47.4", "48", "48.6", "49.2", "49.8", "50.4", "51", "51.6", "52.2", "52.8", "53.4", "54", "54.6", "55.2", "55.8", "56.4", "57", "57.6", "58.2", "58.8", "59.4", "60", "60.6", "61.2", "61.8", "62.4", "63", "63.6", "64.2", "64.8", "65.4", "66", "66.6", "67.2", "67.8", "68.4", "69", "69.6", "70.2", "70.8", "71.4", "72", "72.6", "73.2", "73.8", "74.4", "75", "75.6", "76.2", "76.8", "77.4", "78", "78.6", "79.2", "79.8", "80.4", "81", "81.6", "82.2", "82.8", "83.4", "84");    additionalamountsmatrix[2] = new array("7", "7.7", "8.4", "9.1", "9.8", "10.5", "11.2", "11.9", "12.6", "13.3", "14", "14.7", "15.4", "16.1", "16.8", "17.5", "18.2", "18.9", "19.6", "20.3", "21", "21.7", "22.4", "23.1", "23.8", "24.5", "25.2", "25.9", "26.6", "27.3", "28", "28.7", "29.4", "30.1", "30.8", "31.5", "32.2", "32.9", "33.6", "34.3", "35", "35.7", "36.4", "37.1", "37.8", "38.5", "39.2", "39.9", "40.6", "41.3", "42", "42.7", "43.4", "44.1", "44.8", "45.5", "46.2", "46.9", "47.6", "48.3", "49", "49.7", "50.4", "51.1", "51.8", "52.5", "53.2", "53.9", "54.6", "55.3", "56", "56.7", "57.4", "58.1", "58.8", "59.5", "60.2", "60.9", "61.6", "62.3", "63", "63.7", "64.4", "65.1", "65.8", "66.5", "67.2", "67.9", "68.6", "69.3", "70", "70.7", "71.4", "72.1", "72.8", "73.5", "74.2", "74.9", "75.6", "76.3", "77", "77.7", "78.4", "79.1", "79.8", "80.5", "81.2", "81.9", "82.6", "83.3", "84", "84.7", "85.4", "86.1", "86.8", "87.5", "88.2", "88.9", "89.6", "90.3", "91", "91.7", "92.4", "93.1", "93.8", "94.5", "95.2", "95.9", "96.6", "97.3", "98");    additionalamountsmatrix[3] = new array("8", "8.8", "9.6", "10.4", "11.2", "12", "12.8", "13.6", "14.4", "15.2", "16", "16.8", "17.6", "18.4", "19.2", "20", "20.8", "21.6", "22.4", "23.2", "24", "24.8", "25.6", "26.4", "27.2", "28", "28.8", "29.6", "30.4", "31.2", "32", "32.8", "33.6", "34.4", "35.2", "36", "36.8", "37.6", "38.4", "39.2", "40", "40.8", "41.6", "42.4", "43.2", "44", "44.8", "45.6", "46.4", "47.2", "48", "48.8", "49.6", "50.4", "51.2", "52", "52.8", "53.6", "54.4", "55.2", "56", "56.8", "57.6", "58.4", "59.2", "60", "60.8", "61.6", "62.4", "63.2", "64", "64.8", "65.6", "66.4", "67.2", "68", "68.8", "69.6", "70.4", "71.2", "72", "72.8", "73.6", "74.4", "75.2", "76", "76.8", "77.6", "78.4", "79.2", "80", "80.8", "81.6", "82.4", "83.2", "84", "84.8", "85.6", "86.4", "87.2", "88", "88.8", "89.6", "90.4", "91.2", "92", "92.8", "93.6", "94.4", "95.2", "96", "96.8", "97.6", "98.4", "99.2", "100", "100.8", "101.6", "102.4", "103.2", "104", "104.8", "105.6", "106.4", "107.2", "108", "108.8", "109.6", "110.4", "111.2", "112");    additionalamountsmatrix[4] = new array("9.5", "10.45", "11.4", "12.35", "13.3", "14.25", "15.2", "16.15", "17.1", "18.05", "19", "19.95", "20.9", "21.85", "22.8", "23.75", "24.7", "25.65", "26.6", "27.55", "28.5", "29.45", "30.4", "31.35", "32.3", "33.25", "34.2", "35.15", "36.1", "37.05", "38", "38.95", "39.9", "40.85", "41.8", "42.75", "43.7", "44.65", "45.6", "46.55", "47.5", "48.45", "49.4", "50.35", "51.3", "52.25", "53.2", "54.15", "55.1", "56.05", "57", "57.95", "58.9", "59.85", "60.8", "61.75", "62.7", "63.65", "64.6", "65.55", "66.5", "67.45", "68.4", "69.35", "70.3", "71.25", "72.2", "73.15", "74.1", "75.05", "76", "76.95", "77.9", "78.85", "79.8", "80.75", "81.7", "82.65", "83.6", "84.55", "85.5", "86.45", "87.4", "88.35", "89.3", "90.25", "91.2", "92.15", "93.1", "94.05", "95", "95.95", "96.9", "97.85", "98.8", "99.75", "100.7", "101.65", "102.6", "103.55", "104.5", "105.45", "106.4", "107.35", "108.3", "109.25", "110.2", "111.15", "112.1", "113.05", "114", "114.95", "115.9", "116.85", "117.8", "118.75", "119.7", "120.65", "121.6", "122.55", "123.5", "124.45", "125.4", "126.35", "127.3", "128.25", "129.2", "130.15", "131.1", "132.05", "133");    additionalamountsmatrix[5] = new array("11", "12.1", "13.2", "14.3", "15.4", "16.5", "17.6", "18.7", "19.8", "20.9", "22", "23.1", "24.2", "25.3", "26.4", "27.5", "28.6", "29.7", "30.8", "31.9", "33", "34.1", "35.2", "36.3", "37.4", "38.5", "39.6", "40.7", "41.8", "42.9", "44", "45.1", "46.2", "47.3", "48.4", "49.5", "50.6", "51.7", "52.8", "53.9", "55", "56.1", "57.2", "58.3", "59.4", "60.5", "61.6", "62.7", "63.8", "64.9", "66", "67.1", "68.2", "69.3", "70.4", "71.5", "72.6", "73.7", "74.8", "75.9", "77", "78.1", "79.2", "80.3", "81.4", "82.5", "83.6", "84.7", "85.8", "86.9", "88", "89.1", "90.2", "91.3", "92.4", "93.5", "94.6", "95.7", "96.8", "97.9", "99", "100.1", "101.2", "102.3", "103.4", "104.5", "105.6", "106.7", "107.8", "108.9", "110", "111.1", "112.2", "113.3", "114.4", "115.5", "116.6", "117.7", "118.8", "119.9", "121", "122.1", "123.2", "124.3", "125.4", "126.5", "127.6", "128.7", "129.8", "130.9", "132", "133.1", "134.2", "135.3", "136.4", "137.5", "138.6", "139.7", "140.8", "141.9", "143", "144.1", "145.2", "146.3", "147.4", "148.5", "149.6", "150.7", "151.8", "152.9", "154");    $("#additionalprecentdiv0").text(additionalamountsmatrix[0][amount]);    $("#additionalprecentdiv1").text(additionalamountsmatrix[1][amount]);    $("#additionalprecentdiv2").text(additionalamountsmatrix[2][amount]);    $("#additionalprecentdiv3").text(additionalamountsmatrix[3][amount]);    $("#additionalprecentdiv4").text(additionalamountsmatrix[4][amount]);    $("#additionalprecentdiv5").text(additionalamountsmatrix[5][amount]);      }
#yw0,    #yw1,    #yw2,    #yw3 {      width: 300px;    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">  <table class="pull-right" style="border:1px solid;float:right;width:170px;">    <tr>      <td>credit amount:</td>      <td id="amount2div">50</td>    </tr>    <tr>      <td>commission:</td>      <td id="pricediv">0</td>    </tr>    <tr>      <td>total:</td>      <td id="alldiv">51.6</td>    </tr>  </table>  <div class="calculator">    <div class="slider_wrapper">      <div id="yw0"></div>    </div>    <div class="value" id="amountsdiv">50      <input value="0" size="1" readonly="readonly" name="credit[amount]" id="credit_amount" type="hidden" />    </div>    <div class="slider_wrapper2">      <div id="yw1"></div>    </div>    <div class="value2" id="durationdiv">5</div>    <input value="0" size="1" readonly="readonly" name="credit[amount]" id="credit_amount" type="hidden" />    <input value="0" size="1" readonly="readonly" name="credit[amount]" id="credit_amount2nd" type="hidden" />    <input value="0" size="1" readonly="readonly" name="credit[duration]" id="credit_duration" type="hidden" />  </div>

a possible theory had :

jquery('#yw0').slider({     'range': 'max',     'min': 0,     'max': 130,     'slide': function(event, ui) {          $("#amountsdiv").text(getamount(ui.value));          generateadditionalprecents(ui.value);          refreshvalues();          var vareset = 0;          if (parseint($("#amountsdiv").text()) > "200") {             $('#t2').removeclass('not-active');             if (vareset == 0) {                 ui.value = 0;                 vareset = 1;             };               $("#credit_amount2nd").val(ui.value);         } else {             $('#t2').addclass('not-active');             $("#credit_amount").val(ui.value);         };      },     'value': 0 }); 

after trying though, value of credit_amount2nd changes 0 , sticks there not incrementing anymore?


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -