Changes

Remove Options from a Combo Box Using JavaScript

481 bytes added, 20:23, 16 September 2010
m
Remove One or More Options
</pre>
 
''Example 3,''
 
<pre>
 
function RemoveBranches()
{
var i=0;
var frm=document.form1;
if(frm){
// Note: this loop starts at the bottom to avoid skipping any due to re-indexing as they are removed.
for(i=(frm.branchid.options.length-1);i>=0;i--){
if (frm.branchid.options[i].value!=1111 && frm.branchid.options[i].value!=2222 && frm.branchid.options[i].value!=3333 &&frm.branchid.options[i].value!=4444){
frm.branchid.remove(i);
}
}
}
}
RemoveBranches();
 
</pre>
 
If you wish to control this by [[Role|role]] (for example if you want a role to be able to view existing Level 2 records of a given [[Type]], but not create them...)
::''Note that you must test for greater than or equal to 0. If the role is the first listed in the [[User|user]]'s role list it will return a 0 rather than a 1 because of the preceding comma.''
 
==To Remove All Options Except the Selected==
214
edits