Reputation: 91
In javascript we can do a form submit using
document.getElementById('edit').form.submit();
I want to know how we can do this using IHTMLElement
in C++?
I tried getting the form element from the page and used IHTMLElement->click()
api.
But no action is performed.
How can I get a "FORM" element from the page and do the submit?
Upvotes: 1
Views: 891
Reputation: 20063
Once you have retrieved an IHTMLElement from the document use QueryInterface
to get a pointer to the IHTMLFormElement
interface. One you've done that call submit()
.
IHTMLFormElement *form;
hr = element->QueryInterface(
IID_IHTMLFormElement,
reinterpret_cast<void**>(&form));
if(!FAILED(hr))
{
form->submit();
form->Release();
}
Keep in mind that this will not fire the forms onsubmit
event. You will need to do that yourself by calling HTMLFormElementEvents::onsubmit
which can be done in much the same way as the submit
example above.
Upvotes: 1