I am working in PHP and I have an add item
button on a page that when the user clicks will pop up a window using the tinybox.js
script. The pop up window is a PHP page itself that retrieves some data from a db. On this pop up page I have some JavaScript with a + and - button so that the user can change a quantity. This works perfectly when loading the page directly but it seems that the JavaScript will not run when the page is a pop up.
Can anyone please tell me what I need to do to get the code to work on the pop up.
Here is the javascript for the change quantity buttons:
$(".ddd").on("click", function () {
var $button = $(this),
$input = $button.closest('.set-quantity').find("input.quantity-input");
var oldValue = $input.val(),
newVal;
if ($.trim($button.text()) == "+") {
newVal = parseFloat(oldValue) + 1;
} else {
// Don't allow decrementing below zero
if (oldValue > 1) {
newVal = parseFloat(oldValue) - 1;
} else {
newVal = 1;
}
}
$input.val(newVal);
});