Skip to content

Commit

Permalink
only show location total when more than one location; better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Irwin committed Oct 14, 2014
1 parent ad828a8 commit 66e0a58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
.done(function(data) {
$("#details-form").html(data); // load form fields
$("#datepicker").datepicker(); //trigger datepicker

// for counts with more than one location, display
// sum of all location counts
$(".counts").bind("keyup", function () {
var total = 0;
$(".counts").each(function(e) {
Expand All @@ -28,9 +31,10 @@
}); //end each count
$("#sum-counts").html(total);
}); //end keyup
});
}
}); //end on click delete-link

}); //end js-actions on successful AJAX load
} //end else if there's an initiative ID
}); //end on selection of initiative from pulldown
}); //end document ready

</script>
Expand Down
1 change: 0 additions & 1 deletion load_fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<input name="time" type="text" /><br />
<h4>Counts by location</h4>
<?php echo($location_inputs); ?>
<div id="display-counts">Total Counts: <span id="sum-counts"></span></div>
<?php echo($activity_inputs);?>
<br /> <input type="submit" />
</form>
5 changes: 5 additions & 0 deletions scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ function GetLocations($initiative) {
$location_inputs = "";
$q = "SELECT `location`.`id` as loc_id,`location`.`title` as loc_title from `location`,`initiative` where `location`.`enabled` = '1' and `location`.`fk_parent` = `initiative`.`fk_root_location` and `initiative`.`id` = '$initiative'";
$r = mysql_query($q);
$field_count = mysql_num_rows($r);
while ($myrow = mysql_fetch_assoc($r)) {
extract($myrow);
$locs[$loc_id] = $loc_title;
$location_inputs .= "<label for=\"counts[$loc_id]\">$loc_title</label>\n";
$location_inputs .= "<input name=\"counts[$loc_id]\" type=\"text\" class=\"counts\"><br />\n";
} //end while locations
if ($field_count > 1) {
$location_inputs .= '<div id="display-counts">Total Counts: <span id="sum-counts"></span></div>';
}

return($location_inputs);
} //end function GetLocations

Expand Down

0 comments on commit 66e0a58

Please # to comment.