Avatar of Oliver Wastell
Oliver Wastell
Flag for United Kingdom of Great Britain and Northern Ireland asked on

How can I programmatically click on an image button to submit a form

Hi Experts,

I am using the IE web browser object in a MS Access form to automatically log into my online telephone account, although I am having a problem submitting the form.  I am using the following visual basic code:

    WebBrowserCallagenix.navigate "http://www.callagenix.com/"
    DoEvents: DoEvents: DoEvents
    Do While WebBrowserCallagenix.Busy   'wait until the page loads by looping
      DoEvents
    Loop
    Set doc = WebBrowserCallagenix.Document    'access the document properties
    DoEvents
    Do While WebBrowserCallagenix.Busy
        DoEvents
    Loop  
    returnValue = FillForm("pAccountCode", "my_account", False)
    returnValue = FillForm("pPassword", "my_password", False)
    WebBrowserCallagenix.Document.Forms("cgxlogin").submit

The above code enters the account name and password into the appropriate fields but I then receive the following error message:
 'Object doesn't support this property or method'

I think the issue is to do with the fact that the form uses the post method and/or an image for the login button, but this doesn't help me figure out how to submit the form.

Any ideas?

Here is the html code for the form itself:


<form name="cgxlogin" target="_top" id="cgxlogin" method="post" action="https://secure.callagenix.com/Pages/login/login.asp">
<label for="Account">Account</label><br />                    
<input name="pAccountCode" type="text" class="formfieldreg" id="pAccountCode" size="10" maxlength="10" />
<br />
<label for="Password">Password</label><br />                    
<input name="pPassword" type="password" class="formfieldreg" id="pPassword" size="10" maxlength="10" />
<input type="hidden" name="Submit" value="Login" />
<input name="imageField" type="image" id="login-button" src="images/new/button-login.gif" alt="Login" />
<a href="/registration/register.asp" title="Create New Account"><img src="images/new/button-reg.gif" alt="Register" width="76" height="26" border="0" /></a>
</form>

Open in new window

Web BrowsersWeb ComponentsVisual Basic Classic

Avatar of undefined
Last Comment
Oliver Wastell

8/22/2022 - Mon
Mike_Carroll

There are a variety of ways to do this and there are details here http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
Oliver Wastell

ASKER
Hi Mike, thank you for your comment.  I should have made it clear that the form is on a third party website (www.callagenix.com) so I cannot alter the source html.  The code for the form used is provided in the original question posted and this I cannot change.  What I need to know is how can I submit it by interacting with the Microsoft browser's DOM.

Any thoughts?
paisleym

Hi

I programmed a solution to this in php, and basically what you have to do is to call the click event of the button name, i.e. loop through all the elements to get the button's name.

hth
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Oliver Wastell

ASKER
Hi Paisleym, I have tried the following:
  WebBrowserCallagenix.Document.Forms("cgxlogin").elements("imageField").Click
but as it is not a button and is instead an image I get the following error message.
'Object variable or With block variable not set'
Clicking on the image in the browser control does submit the form though.
SOLUTION
paisleym

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
hes

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Oliver Wastell

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.