Skip to content

Instantly share code, notes, and snippets.

@kristjan
Created January 20, 2011 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristjan/788952 to your computer and use it in GitHub Desktop.
Save kristjan/788952 to your computer and use it in GitHub Desktop.
Count the number of friends you've selected in a FB inviter
function updateTotalSelected(form) {
var totalSelected = getTotalSelected(form);
var elem = getElementsByClassName(form, 'current_selected', 'span')[0];
elem.setTextValue(totalSelected)
}
function getTotalSelected(form) {
var serializedForm = form.serialize();
var ids = serializedForm.ids;
if (!ids) {
return 0;
}
var totalSelected = 0;
for (var i in ids) {
totalSelected++;
}
return totalSelected;
}
<fb:request-form type="cause" invite="true"
onclick="updateTotalSelected(this)" ...>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment