Results 1 to 8 of 8

Thread: click two input buttons in form. both buttons have the same value

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Posts
    21

    Unhappy click two input buttons in form. both buttons have the same value

    Hello guys,

    I have a form (see below), where I need to select a value from the select list, then I click "Go", page loads, then I select another value from the second list, then I click in the second "Go" button.

    The problem is, both buttons have the same value's name ("GO").

    How can I make the difference between the first and second button when clicking?

    This seems to be easy, but still don't find the solution.

    Thanks in advance!

    Code:
    <form name="countrySelection">
     <select name="continent">
      </select>
     <input type="submit" class="go" value="GO" />
     <select name="country">
     </select>
     <input type="submit" alt="Go" value="GO"/>
    </form>

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: click two input buttons in form. both buttons have the same value

    First of all this is not VB code so it really doesn't belong here.
    Second why would you have 2 submit buttons with the same value on the same form?

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: click two input buttons in form. both buttons have the same value

    Thread moved to the ASP, VB-Script forum even though it might not belong here either.

    Give the elements their own name.
    Code:
    <input type="button" value="GO" name="firstGo" />

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Posts
    21

    Re: click two input buttons in form. both buttons have the same value

    I have tried the first so far without success.

    For the first button:

    Code:
    Set ElementCol = objIE.document.getElementsByTagName("input")
    For Each btn In ElementCol
     If btn.getAttribute("class") = "go" And btn.value = "GO" Then
      btn.click
     End If
    Next
    For the second button:

    Code:
    Set ElementCol = objIE.document.getElementsByTagName("input")
    For Each btn In ElementCol
     If btn.getAttribute("alt") = "go" And btn.value = "GO" Then
      btn.click
     End If
    Next
    No luck so far.

    Thanks...

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: click two input buttons in form. both buttons have the same value

    getElementByName

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Posts
    21

    Re: click two input buttons in form. both buttons have the same value

    Quote Originally Posted by DataMiser View Post
    Second why would you have 2 submit buttons with the same value on the same form?
    that's the question I ask myself. the problem is, I didn't create the page, and I am unable to change the value. I have to work with the code as it is.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Posts
    21

    Re: click two input buttons in form. both buttons have the same value

    Quote Originally Posted by Joacim Andersson View Post
    getElementByName
    can you ellaborate more of how can getElementSByName can be applied to click the first and the second Go?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Posts
    21

    Re: click two input buttons in form. both buttons have the same value

    Quote Originally Posted by Joacim Andersson View Post
    getElementByName
    can you ellaborate more of how can getElementSByName can be applied to click the first and the second Go?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width