Difference between revisions of "User:Areid/common.js"

From ipswichmakerspace
Jump to: navigation, search
m (Blanked the page)
m
Line 1: Line 1:
 +
$('#firstHeading').text('Working!');
 +
var $subtotals = $('tr td b').filter(function(i) { return $(this).text()=='£subtotal'; });
  
 +
console.log($subtotals[0]);
 +
 +
 +
console.log('---');
 +
var prior = '';
 +
$subtotals.each(function(i, e) {
 +
 +
if (prior=='') {
 +
prior = $(e).parent().parent().prev().children('td:nth-child(3)').text().trim();
 +
}
 +
 +
//p = $($subtotals.first()).parent().parent().prev().children('td:nth-child(3)').text().trim();
 +
$costs = $('td:contains('+p+')').nextAll('td:nth-child(7)');
 +
var costotal, cost = 0;
 +
$costs.each(function(ci,ce) {
 +
cost = parseFloat($ce.text().trim().replace('£',''));
 +
costotal += cost;
 +
});
 +
 +
$(e).text('£' + costotal);
 +
console.log(p);
 +
console.log(costotal);
 +
 +
});

Revision as of 09:12, 28 January 2018

$('#firstHeading').text('Working!');
var $subtotals = $('tr td b').filter(function(i) { return $(this).text()=='£subtotal'; });

console.log($subtotals[0]);


console.log('---');
var prior = '';
$subtotals.each(function(i, e) {

	if (prior=='') {
		prior = $(e).parent().parent().prev().children('td:nth-child(3)').text().trim();
	}

	//p = $($subtotals.first()).parent().parent().prev().children('td:nth-child(3)').text().trim();
	$costs = $('td:contains('+p+')').nextAll('td:nth-child(7)');
	var costotal, cost = 0;
	$costs.each(function(ci,ce) {
		cost = parseFloat($ce.text().trim().replace('£',''));
		costotal += cost;
	});

	$(e).text('£' + costotal);
	console.log(p);
	console.log(costotal);
 
});