FBML dynamic select adding/removing values
Here is a quick example for adding and removing options from a single select list with FBJS. Hope it helps since I've spent some time figuring it out. :)
Add option to select list in FBML / FBJS 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 / FBJS 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('');
}
| < Prev | Next > |
|---|