Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function kodep(value) {
- var idkode = []
- var kodekatagori = value.split(" ").filter(function (e) {
- return e.trim().length > 0;
- });
- for (i = 0; i < kodekatagori.length; i++) {
- if (kodekatagori.length == 1) {
- var code = kodekatagori[i].slice(0, 2)
- } else {
- var code = kodekatagori[i].slice(0, 1)
- }
- idkode.push(code)
- }
- var kodepr = idkode.join("")
- kodepr = kodepr.toUpperCase()
- if (idkode.length == 0) {
- document.getElementById("kodeProduk").value = ''
- } else {
- var count = 1;
- for (i = 0; i < kategori.length; ++i) {
- if (kategori[i].toLowerCase() == value.toLowerCase()) {
- count++;
- }
- }
- if (count < 10) {
- document.getElementById("kodeProduk").value = kodepr + '-00' + count
- } else if (count < 100) {
- document.getElementById("kodeProduk").value = kodepr + '-0' + count
- } else {
- document.getElementById("kodeProduk").value = kodepr + '-' + count
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement