<span id="verificationInfo_ecdDOBMonth"><select name="verificationInfo:ecdDOBMonth:month" id="verificationInfo_ecdDOBMonth_month" onmousewheel="return false;" style="width:160px;">
<option selected="selected" value=""></option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option> </select>void InputSelect(IHTMLElementCollection *pobjElement,CString strName,int tmp,int itemno)
{
CComPtr<IDispatch>pDisp;
pobjElement->item(COleVariant(strName),COleVariant((long)itemno),&pDisp);
CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement>Pelement;
if(pDisp==NULL)
{
AfxMessageBox(strName+"没有找到!");
}
else
{
Pelement=pDisp;
Pelement->put_selectedIndex(tmp);
}
}
上面分别是html代码跟c++的代码
我这样调用的 InputSelect(objAllElement,_T("verificationInfo:ecdDOBMonth:month"),5,1);
很奇怪 会提示"没有找到!"pDisp的值为变成NULL 不知道该如何调用了。
<option selected="selected" value=""></option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option> </select>void InputSelect(IHTMLElementCollection *pobjElement,CString strName,int tmp,int itemno)
{
CComPtr<IDispatch>pDisp;
pobjElement->item(COleVariant(strName),COleVariant((long)itemno),&pDisp);
CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement>Pelement;
if(pDisp==NULL)
{
AfxMessageBox(strName+"没有找到!");
}
else
{
Pelement=pDisp;
Pelement->put_selectedIndex(tmp);
}
}
上面分别是html代码跟c++的代码
我这样调用的 InputSelect(objAllElement,_T("verificationInfo:ecdDOBMonth:month"),5,1);
很奇怪 会提示"没有找到!"pDisp的值为变成NULL 不知道该如何调用了。
貌似IHtmlElementCollection中的item不支持name,只支持数字