Created
November 16, 2020 22:19
-
-
Save salsalabs/5667aaa459b0f8f13f64897c64648233 to your computer and use it in GitHub Desktop.
Provide a age group box for a client. The age group box is a <select> with a series of checkboxes inside.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- BEGIN SalsaStaff 366219: Put a fieldset containing "nn-nn years old" optional groups after the Organization field in a | |
Salsa Classic form. The optional groups are all of subgroups to the "Age Groups" group. | |
The age group box will apppear on any page that has | |
1. "An Organization" field. | |
2. This special html. | |
<div style="display: none;" id="show-age-group-box"></div> | |
The best place for the HTML is in the Pre-Submit footer on any Classic page. If there's a page without a Pre-Submitter, then put | |
the HTML in any field that does not have a WYSIWYG editor. | |
--> | |
<div class="formRow"> | |
<fieldset id="age-group-fieldset" style="display: none;"> | |
<legend>What age group(s) of young people does your organization work with?</legend> | |
<ul> | |
<? | |
// SalsaScript to retrieve the groups whose parent is "Age Groups" (groups_KEY 177130). | |
// The results are stored in a hidden fieldset. | |
var groups = DB.getObjects("groups", { conditions: [ new Condition("parent_KEY", "=", "177130") ], orderBy: "groups_KEY" }); | |
for each(g in groups) { | |
?> | |
<li> | |
<input type="hidden" name="link" value="groups"> | |
<input id="add_to_groups_KEY<?= g.groups_KEY ?>_checkbox" type="checkbox" value="<?= g.groups_KEY ?>" name="linkKey"> | |
<label for="add_to_groups_KEY<?= g.groups_KEY ?>_checkbox"><?= g.Group_Name ?></label> | |
</li> | |
<? | |
} | |
?> | |
</ul> | |
</fieldset> | |
</div> | |
<script type="text/javascript"> | |
$(document).ready(() => { | |
if ($('#show-age-group-box').length > 0) { | |
var target = $("input[name='Organization']").parent(); | |
if (target.length == 0) { return; } | |
$("#age-group-fieldset").insertAfter(target); | |
$("#age-group-fieldset").show(); | |
} | |
}); | |
</script> | |
<style type="text/css"> | |
#age-group-fieldset { | |
margin-bottom: 10px; | |
/* Width matches dropdown... */ | |
width: 450px; | |
border: 1pt solid black; | |
padding: 0px; | |
} | |
#age-group-fieldset legend { | |
font-weight: normal !important; | |
text-transform: initial; | |
border: none; | |
width: auto; | |
display: inline-block; | |
margin-left: 20px; | |
padding-left: 10px; | |
padding-right: 10px; | |
} | |
#age-group-fieldset ul { | |
list-style-type: none; | |
margin-bottom: 0px; | |
} | |
</style> | |
<!-- END SalsaStaff 366219: Put a fieldset containing age group optional groups after the Organization field in a form. --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
A client-specific solution to add an age group box to a Salsa Classic page.
Product
Restrictions
This solution is only valid for donation pages and signup pages.
If you need to use another type of page (for example, a targeted action), then please send mail to [email protected]. We'll be glad to help.
What you need
Installation
Is it already installed?
The first step is to figure out if the script is already installed. Here are some steps you can use.
Install into the template
</body>
tag.</body>
tag.</body>
tag.Configuration
The next step is to configure the donation/signup page so that the group age box appears.
Donation pages
Signup pages
Testing
The best way to know if the solution was properly installed is to view the page that you just edited. You'll know you're successful if you see the age group box just under the "Occupation" field.
Questions? Comments?
If you have any questions or comments, then please gather this information.
Send the gathered info to [email protected]. We'll be glad to help,