Feya
asked on
How to set "Selected" status of a radio in WebBrowser2 Ctrl?
Hi experts:
I want to set a HTML radio to the status of selected, the html code is here:
<input type="radio" name="myradio" value="Value1">Radio Box Value1
<input type="radio" name="myradio" value="value2">Radio Box Value1
You can see that the two radio is unselected. I want to press a button in my program and select the radio which value="value2".
Please note:
1 They have same name because they are in one group.
2 I can set the *value* of text input box, but the "selected" status is not the value of radio. When a radio is selected, the html code will be:
<input type="radio" name="myradio" value="Value1" selected>
3 I also want to know how to check/uncheck a check box in WebBrowser2 ctrl.
The following can set value of text input box of CWebBrowser2 m_web;
IHTMLElementCollection *objAllElement=NULL;
IHTMLDocument2 *objDocument=NULL;
CComPtr<IDispatch>pDisp;
IHTMLAnchorElement *objAnchor=NULL;
CString strUrl;
strUrl=m_ctrlWeb.GetLocati onURL();
if(strUrl.IsEmpty())
return;
objDocument=(IHTMLDocument 2 *)m_ctrlWeb.GetDocument();
objDocument->get_all(&objA llElement) ;
objAllElement->item(COleVa riant("Nam e of Textbox"),COleVariant((lon g)0),&pDis p);
CComQIPtr<IHTMLInputTextEl ement, &IID_IHTMLInputTextElement >pElement;
//If it is a radio box , then use IHTMLOptionButtonEelment here
pElement=pDisp;
pElement->put_value(CStrin g("Value of Textbox").AllocSysString() );
I want to set a HTML radio to the status of selected, the html code is here:
<input type="radio" name="myradio" value="Value1">Radio Box Value1
<input type="radio" name="myradio" value="value2">Radio Box Value1
You can see that the two radio is unselected. I want to press a button in my program and select the radio which value="value2".
Please note:
1 They have same name because they are in one group.
2 I can set the *value* of text input box, but the "selected" status is not the value of radio. When a radio is selected, the html code will be:
<input type="radio" name="myradio" value="Value1" selected>
3 I also want to know how to check/uncheck a check box in WebBrowser2 ctrl.
The following can set value of text input box of CWebBrowser2 m_web;
IHTMLElementCollection *objAllElement=NULL;
IHTMLDocument2 *objDocument=NULL;
CComPtr<IDispatch>pDisp;
IHTMLAnchorElement *objAnchor=NULL;
CString strUrl;
strUrl=m_ctrlWeb.GetLocati
if(strUrl.IsEmpty())
return;
objDocument=(IHTMLDocument
objDocument->get_all(&objA
objAllElement->item(COleVa
CComQIPtr<IHTMLInputTextEl
//If it is a radio box , then use IHTMLOptionButtonEelment here
pElement=pDisp;
pElement->put_value(CStrin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER