HTML optgroup element creates a grouping of options within a select element in web page. You might be working on optgroup in select box.
Here is the simple script for the addition and deletion of optgroups.
Adding optgroup
var selectbox = document.getElementById("ProductIssueField");
var combinationGroup = document.createElement("optgroup");
combinationGroup.label = GroupName;
selectbox.appendChild(combinationGroup);
Removinging optgroup
var obj = document.getElementById("ALLUSER");
var ogl=obj.getElementsByTagName('optgroup');
for (var i=ogl.length-1;i>=0;i--)
obj.removeChild(ogl[i])
It helped me a lot.. Thanks...
ReplyDeletethanks for your script.
ReplyDelete