チェックボックスを“チェック済み”に設定する方法mshtmlを使用していますか?
質問
mshtmlで必要なことはほとんどできますが、チェックボックスの入力要素を「checked」に設定する方法に少し行き詰っています。状況は次のとおりです...
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
}
}
ご協力いただきありがとうございます!
グレッグ
解決
HTMLInputElement は、Checkedプロパティをブール値
他のヒント
プレーンなJavaScriptでは、チェックボックス要素には checked
プロパティがあります。したがって、[プレーンJavaScript]で次のように記述できます。
document.getElementById("myCheckbox").checked = true;
.NETまたはそこで使用しているものは何でもわかりませんが、同様の方法でそれを行う可能性があります。
スティーブ
所属していません StackOverflow