Home Programming Facebook platform FBML dynamic select adding/removing values

FBML dynamic select adding/removing values

E-mail Print
Share/Save/Bookmark
Here is a quick example for adding and removing options from a single select list. Hope it helps since I've spent some time figuring it out. :)

Add option to select list in FBML with appendChild()

function addOption(id, value, text) {
var select = document.getElementById(id);
var option = document.createElement('option');
option.setValue(value).setTextValue(text);
select.appendChild(option);
}

Remove option from select list in FBML with removeChild()

var choiceList = document.getElementById('someID');

var count = choiceList.getOptions().length - 1;
var node = choiceList.getOptions()[count];
choiceList.removeChild(node);

Clear all options at once

function clearAllOptions(id) {
document.getElementById(id).setTextValue('');
}
Hits: 888
Comments (1)Add Comment
December 18, 2009     
thx
Just thanx for the job.
I'm new in FBJS and thx to your work I avoid to spend a lot of time
Cdric | 82.241.105.233

Write comment

busy
Last Updated ( Friday, 30 October 2009 21:11 )  

Sponsored Links

My friends

Bookingpoint
partner websites

Donate

Do you find content useful? Please donate so I can cover my hosting expenses! Thanks!