Junal on the run

A getChecked() example with FBJS.

Posted on: March 24, 2008

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…

<script>

function checkIfFriendsSelected()
{
var ok = false;
for(var i=0; i<totalFriends; i++)
{
var item = “m”+i;
if(document.getElementById(item).getChecked()==true) {
ok = true;
}
}
if(!ok)

{
new Dialog(Dialog.DIALOG_POP).showMessage(‘Select A Friend’, ‘You must select a friend to send a poke!’, button_confirm = “Okay”);
return false;
}
else
{
return true;
}

}

</script>

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()”.

FBJS example with getChecked() Method

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”🙂

2 Responses to "A getChecked() example with FBJS."

Hi Md.Mizanur Rahman Junal,
Nice content… i cant see anywhere google ads?…
I think so you are getting good traffic… why dont u use google ads…

Is wordpress not support google ads?…

heh heh – actually i dont like ads. dont want to make a simple thing clumsy…thanks for your comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

View Junal Rahman's profile on LinkedIn
Subscribe to me on FriendFeed

Follow Me on Twitter

Archives

My photos

Downtown, Ottawa

Dream

Jasper, AB

Jasper, AB

Banff, AB

Folkfest, Bangladesh Pavilion Saskatoon

Lovely Sky

Stunt bikers on summer festival, Saskatoon

More Photos

Blog Stats

  • 420,271 hits
%d bloggers like this: