A getChecked() example with FBJS.
Posted March 24, 2008on:
I didn’t find any example of getChecked(), so I thought this example might help somebody who are looking for an example using this method.
Problem: You would like to allow your users to send their Facebook’s friends a message or whatever. Now there must be a check (if this is not invitations, because in invitation you don’t need to check whether friends are selected or not) to see if any friend is selected for the action.
Solution: We can solve it by FBJS using getChecked() method. Certainly, your friend’s list generated dynamically. So let’s see the solution…
var ok = false;
for(var i=0; i<totalFriends; i++)
var item = “m”+i;
ok = true;
new Dialog(Dialog.DIALOG_POP).showMessage(‘Select A Friend’, ‘You must select a friend to send a poke!’, button_confirm = “Okay”);
Your function is created, now you need to call this. note one thing that we can call this function when we click on a button but problem is if we do so, form will still be submitted because “form submit” doesn’t work for FBJS! So we better set this function on “onsubmit” in the form tag like this : onsubmit=”return checkIfFriendsSelected()”.
now, if your users dont select any friend then it will show a pop-up message like the above one …
caution : input type must be “checkbox”🙂