From 508ed7c3b96033c645124d3342de2e4d7f7d41d4 Mon Sep 17 00:00:00 2001 From: Jonathan Rosenbaum Date: Fri, 26 Dec 2014 06:26:26 +0000 Subject: [PATCH] jQuery - when paid checkbox is checked/unchecked database is updated. Color changes, too. --- include_header.html | 1 + js/transaction.js | 20 ++++++++++++++++++++ json/transaction.php | 21 +++++++++++++++++++++ transaction_log.php | 11 +++++++++-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 js/transaction.js create mode 100644 json/transaction.php diff --git a/include_header.html b/include_header.html index 4951632..e097838 100644 --- a/include_header.html +++ b/include_header.html @@ -24,6 +24,7 @@ function resetTimer() YBDB + diff --git a/js/transaction.js b/js/transaction.js new file mode 100644 index 0000000..19485bf --- /dev/null +++ b/js/transaction.js @@ -0,0 +1,20 @@ +/* jQuery fun with transactions - Jonathan Rosenbaum */ + +// currently css is just hardwired, but that reflects the coding style of YBDB :) + +$(function() { + + $(".paid").click(function() { + if ($(this).prop("checked")) { + //console.log("turn color on"); + $(this).closest("tr").css("background-color","#99CC33"); + $.post("json/transaction.php",{ paid: 1, transaction_id: this.name } ); + } + else { + //console.log("turn color off"); + $(this).closest("tr").css("background-color","transparent"); + $.post("json/transaction.php",{ paid: 0, transaction_id: this.name } ); + } + }); + +}); \ No newline at end of file diff --git a/json/transaction.php b/json/transaction.php new file mode 100644 index 0000000..bb23dc5 --- /dev/null +++ b/json/transaction.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/transaction_log.php b/transaction_log.php index 1fbdfeb..17f11cd 100644 --- a/transaction_log.php +++ b/transaction_log.php @@ -385,7 +385,10 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
- > + > @@ -393,7 +396,11 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";   edit"; ?> - + + > +