If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Get results from "onclick" actions

Dear JavaScript Users and Developers,

I am new to JavaScript, but have experience in other programming languages. I challenged myself to solve a programming problem that would be useful to me.

There is a web page that I want to extract data from. This should be done in an automated way. Specifically, I want to save and later parse the html markup that an "onclick" link generates. This looks something like this:

The notable thing is that the value in
HTML Code:
auctionResultListForm.auctionResultListIndex.value=0;
gets incremented by 1 for all the links I want to save/parse.

Are you saying you want the click to increment that value? Or that this sort of link appears N times on the page, each setting {}.value to something unique?

In either case, I'm still not sure I understand he question.

You said you "want to save and later parse the html markup that an "onclick" link generates." But, an onclick doesn't inherently generate markup. It's possible that your onlick event triggers a form submission, page load, or AJAX request -- and if that's what you mean to capture, any JavaScript mechanism for capturing the resulting, server-generated markup will be slightly different for each of those scenarios.

Maybe I did not clearly state my goal. I am not building a website. I am trying to "scrape" an existing webpage. I wanted to save and later extract information from the hmtl page that gets displayed to me when I click the link I wrote about.

Are you saying you want the click to increment that value? Or that this sort of link appears N times on the page, each setting {}.value to something unique?

My description was confusing, I see now. Your second guess is right: the link appears N times on the page. I think it sets a

Code:

auctionResultListForm.auctionResultListIndex.value

that is referenced after submitting the form that takes the

Code:

auctionResultListForm

as argument.

But, an onclick doesn't inherently generate markup. It's possible that your onlick event triggers a form submission, page load, or AJAX request -- and if that's what you mean to capture, any JavaScript mechanism for capturing the resulting, server-generated markup will be slightly different for each of those scenarios.

I see. I assume from the posted "onclick" string that it is a form submission (submitForm(auctionResultListForm)). Does this mean that since I have no control over or information on the internal implementation there is no way to capture the html that gets loaded after I click?

As I said, I am not really familiar with web programming and JavaScript, just thought there might be an easy way to do it.

In the meantime, I am trying to use the imacros addon for firefox to automate my clicks and saves of the html pages on disk to later extract the information I want.

Ok. If you just need a button you can click on a page-by-page basis that submits some scraped page content to a server, look into writing a bookmarklet.

It's as simple as adding a link to your links bar with a javascript: URL. The script that follows gets injected into whatever page you're looking at. I use one at svidgen.com to make adding bookmarks easy, sans plugin.