diff --git a/plusminusbutton.js b/plusminusbutton.js index 34232f5..78e31be 100644 --- a/plusminusbutton.js +++ b/plusminusbutton.js @@ -1,37 +1,89 @@ -jQuery(document).ready(function(){ - // This button will increment the value - $('[data-quantity="plus"]').click(function(e){ - // Stop acting like a button - e.preventDefault(); - // Get the field name - fieldName = $(this).attr('data-field'); - // Get its current value - var currentVal = parseInt($('input[name='+fieldName+']').val()); - // If is not undefined - if (!isNaN(currentVal)) { - // Increment - $('input[name='+fieldName+']').val(currentVal + 1); - } else { - // Otherwise put a 0 there - $('input[name='+fieldName+']').val(0); - } +var inputNumber = document.getElementsByClassName('input-group-field'); + +if (window.location.pathname.includes("/warenkorb.html")) { + document.addEventListener("DOMContentLoaded", function () { + $(window).on('load',function() { + for(var y = 0;y 0) { - // Decrement one - $('input[name='+fieldName+']').val(currentVal - 1); - } else { - // Otherwise put a 0 there - $('input[name='+fieldName+']').val(0); - } - }); - }); - \ No newline at end of file +} + +// +//var addItemButton = document.getElementsByClassName("input-group-field"); + +function showValue(event) +{ + + var shopItem = event.parentElement.parentElement.parentElement + + var title = shopItem.getElementsByTagName('h3')[0].innerHTML + var getValue = localStorage.getItem(title) || 0; + shopItem.getElementsByClassName('input-group-field')[0].value = getValue; + +} + +function incrmenetValue(event) +{ + + + var buttony = event.target + var shopItem = buttony.parentElement.parentElement.parentElement.parentElement.parentElement + var title = shopItem.getElementsByTagName('h3')[0].innerHTML + var getValue= localStorage.getItem(title) || 0; + // var getValue = shopItem.getElementsByClassName('input-group-field')[0].value; + if(getValue < 10){ + getValue++; + } + shopItem.getElementsByClassName('input-group-field')[0].value = getValue; + localStorage.setItem(title, getValue) + + +} +function decrmenetValue(event) +{ + var buttony = event.target + var shopItem = buttony.parentElement.parentElement.parentElement.parentElement.parentElement + var title = shopItem.getElementsByTagName('h3')[0].innerHTML + var getValue= localStorage.getItem(title) || 0; + if(getValue > 0){ + getValue--; + } + shopItem.getElementsByClassName('input-group-field')[0].value = getValue; + localStorage.setItem(title, getValue) + + +}