2

私は mshtml で必要なほとんどのことを行うことができますが、チェックボックスの入力要素を「チェック済み」に設定する方法に少しこだわっています。これが状況です...

IHTMLElementCollection inputElements = (IHTMLElementCollection)doc.all.tags("input");
foreach (IHTMLElement el in inputElements)
{
    string elementHtml = el.outerHTML;
    string termsOfServiceIdentifier = "id=chkUTOS_ver2";

    //  select the Terms of Service checkbox
    if (elementHtml.Contains(termsOfServiceIdentifier)) 
    {
        HTMLInputElement chkTOS = (HTMLInputElement)el;
        chkTOS.@checked = true;  //  that's the solution. Thanks Wayne.
     }
     else
     {
        //  do nothing - we're not interested in this element
     }
}

助けてくれてありがとう!

グレッグ

4

2 に答える 2

4

HTMLInputElementは Checked プロパティをブール値として公開します

于 2009-05-02T05:46:19.087 に答える
0

プレーンな JavaScript では、チェックボックス要素にcheckedプロパティがあります。したがって、[プレーンな JavaScript で] 次のように記述できます。

document.getElementById("myCheckbox").checked = true;

.NET やそこで使用しているものはわかりませんが、同様の方法で行う可能性があります。

スティーブ

于 2009-05-02T05:44:56.360 に答える