This is the discussion forum for the HtmlEditor. See also the
HtmlEditor home page, where you can download the control, and the
Documentation Wiki, a collaborative project for documenting the control.
Adding Options to Selectelement
Posted by:
Alex (217.78.175.---)
Date: Thursday, 24-Aug-2006, 13:18:50
Hi there,
does sombody know how to add options to a selectbox?
I use code like this
------------------
HtmlElement he = webdoc.GetElementById("id1");
he.OuterHtml = "<select id=id1 name=myname></select>";
------------------
how can i add options to this element.
if i try
------------------
he.InnerHtml="<option value=1>xxx</option><option value=2></option>";
------------------
after that if i let print he.innerhtml or if i view the he Object, the innerHtml property just contains "xxx</option><option value=2></option>"
so the first "<option value=1>" is missed.
is there another way to add options to the selectelement ?
tank you for help
alex
Re: Adding Options to Selectelement
Posted by:
Brenda (---.hcl.com)
Date: Tuesday, 29-Aug-2006, 20:41:24
Alex,
Try creating the option element, and then adding it to the select element as follows:
IHTMLElement optionElement = htmlDocument2.CreateElement("<option value=1>xxx</option>");
IHTMLDOMNode domNode = he as IHTMLDOMNode;
domNode.appendChild((IHTMLDOMNode)optionElement);
or
IHTMLSelectElement selectionObject = he as IHTMLSelectElement;
selectionObject.add(optionElement, 0);
Brenda.