I’m have some difficulty changing the value of a textbox in twebbrowser. I have tried WebBrowser1.OleObject.Document.getElementById('verification_control_0').value := 'mytext'; and a few other methods but it doesn’t seem to work.
The websites code:
<div id="verification_control_0" class="verification_control">
<div class="smalltext">
What are the first 3 letters of our website's name?:<br />
<input type="text" name="register_vv[q][71]" size="30" value="" tabindex="6" class="input_text" />
</div>
</div>
If you could please show me how to change the value in <input type="text" name="register_vv[q][71]" size="30" value="" tabindex="6" class="input_text" /> i would really appreciate it very much.
Thanks for reading and all replies.
Try this:
In IE8 Standards mode,
getElementByIdperforms a case-sensitive match on theIDattribute only.In IE7 Standards mode and previous modes, this method performs a case-insensitive match on both the
IDandNAMEattributes, which might produce unexpected results.So if your
TWebBrowserworks with IE7 Standards mode and previous modesgetElementByIdshould work as well:Using
getElementsByNamecollection to locate elements byNAMEshould be the preferred solution.EDIT:
@SertacAkyuz first comment:
I’m pretty sure OP did not test your code (which should work by default, unless OP explicitly changed IE browsing mode), and used
getElementByID('verification_control_0')instead – which is aDIVelement and does not have methodvaluesupported. (hence the error message"Method 'value' not supported by automation object").