Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Need help with Click()

    I'm new to JS and i'm trying to write a script that will do something like this:

    If on page #1
    //click button1
    else if on page#2
    //click button2
    else
    //click button3

    To click a button i use:
    document.Form_Name.Button_Name.click();

    It works fine as long as i know the form name and the button name like clicking the search button in google would be:
    document.f.btnG.click();

    But some forms don't have a name. All they have is something like:
    <form action="Link" method="post" onsubmit="this.submit.disabled=true;">
    .
    .
    .
    and the button is:
    <input name="submit" type="submit" onload="this.disabled=false;" value="OK">


    How can i click such a button?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    document.forms[0].buttonName.click();

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • Users who have thanked Philip M for this post:

    w!ck3d (06-19-2009)

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It worked. Thanks.


  •  

    Posting Permissions

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