can we add new <optgroup> dynamically to dynamically generated <select> box?
Are you having specific problems with <optgroup> or do you need to know how to create any new html tag?
The html is rendered on your page already. So, in order to display different html like <optgroup> and <options> you have to insert those tags into the existing hmtl or replace some of the existing html, and that requires that you learn about the wonderful world of the DOM.
Here are some tutorials:
I wants to add new <select> tag and <optgroup> and <options> under this optgroup optgroup under select. how can i create new optgroup and add it to newly createed select.
i know how to add options using .options object of select element reference. i don't know how to create new optgroup and how to add it to select.?
This may or may not help you out
optGroup = document.createElement('optgroup')
optGroup.label = "New Group"
objOption.innerHTML = "Sample1"
objOption.value = "sample1"
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)