All of my code is working properly, I'm just trying to expand it to work for all possibilities, know there must be a better way to do it, but don't think I know javascript well enough (I just started learning).
Essentially, I'm trying to call data from a database based on which checkboxes on my web app are checked. There are four boxes: "committees", "candidates", "individuals", "opinion".
My code is this:
if($('#committees').attr('checked')) {
$.get("file.pl",
{
act: "near",
format: "raw"
what: "committees"
}, NewData);
}
else {
$.get("file.pl",
{
act: "near",
format: "raw"
what: ""
}, NewData);
which works perfectly for just the committees checkbox, (the ids of the other boxes match the table name for the "what", and match the above-stated names. I want to have this work for all 4 checked boxes, without having to make huge nested statements for every possible combination of checked boxes.
I know I can list more options in the "what" category like this:
$.get("file.pl",
{
act: "near",
format: "raw"
what: "committees, candidates, individuals, opinions"
}, NewData);
and that works, but Idk how to dynamically change that string to match which boxes are checked. Thanks for any help you can offer!