How to click a button programatically?

Discussion in 'Web Design, HTML And CSS' started by noamjob, Dec 25, 2008.

  1. noamjob

    noamjob New Member

    Joined:
    Dec 25, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Here is what I need to do:
    Let's say I want to make a program that perform a search by First Name in a site like this(only for demonstration, I'm not spamming...):

    search in google for <draftexpress search> and you'll get an example

    Let's say I want to search for "james".

    How do I do it? I spent many hours on this and couldn't find out...
    The main problem iis that the website is not mine, so how can I access its components?(Let's say I want to "click" the search button there programatically)?
    Is there a way to do it?
    I would appreciate if you expain in details, I'm preety much new in that area...

    thanks,
    Noam
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  3. noamjob

    noamjob New Member

    Joined:
    Dec 25, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    What???
    I think you didn't understand my problem.
    I don't want to perform a search in google. I want to perform a search within a website. I tried to put the hyperlink to the website ao you could see my problem but the forum here doesn't let me do it, so instead I instruct how to find the website I'm talking about: By searching in Google for
    draftexpress search
    and going to the first result there.
    You would see what I'm talking about: there is an option to search players by their first name. In order to do so, you fill the name in the box("james" for example) and then click the "search" button. After you click it, you get directed to a new link with the results - but the new link's name doesn't contain anything like "james"... So I figured out the only way to make my program go to the new page is to make the program actually fill in "james", click the "search" button and then somehow get to the new page with the results. THE PROBLEM is I don't have any clue how to do it...

    Thanks again...
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Yes I know why you are not allowed to place link to site but I am also not suggesting the Google Search but there are 2 ways a form is submitted

    GET and POST

    If they support Get you can use the direct URLs

    Else if they don't then you would need to get form and use the same code for the button click and get a response.

    This means you create a page on your site which can be made to click and then when clicked it gets a results from that site into some frame and then do accordingly.
     
  5. Bhullarz

    Bhullarz New Member

    Joined:
    Nov 15, 2006
    Messages:
    253
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    System Manager
    Home Page:
    http://www.tutors161.com
    yeah . Just chk the behaviour of the website like when you search anything, is the url contains the keyword "you have used" then the simple way is to generate querystring. Otherwise open the webpage's source code and find the form action and then create your own page use the same action page with same variables which were used in original page.
    For the querystring you have to study the URL passed after search. If still problem is there. copy paste the URL here in the board. We will see how can we help you.
     
  6. skp819

    skp819 New Member

    Joined:
    Dec 8, 2008
    Messages:
    89
    Likes Received:
    3
    Trophy Points:
    0
    install firebug.
    right-click on or next to button and select "inspect element"
    find the html tag of the button. it is probably a <input type="button"> tag.
    look for an onclick attrib on the tag, and copy the value of the attribute.
    click the console tab of firebug and pase the code into the console.
    click run, and the result should be the same as clicking the button.


    if there is no onclick attrib, it's a little trickier.
    you need an id for the input.
    if it has one, great.
    if not, while inspecting the input, right click the tag and select "new attribute", type "id" press enter and type "test1" and press enter.

    click back on the console tab and type in $("test1").onclick.toString()

    the code you need to run will appear in red text. copy it and paste it into a function, or run it from the console to simulate a click.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice