Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting to a Form With no Action=...

Status
Not open for further replies.

New3Perl

Programmer
Sep 7, 2009
12
0
0
US
I've written an application using the LWP library that monitors a particular web site for changes in information. This involves having the application log in to the site and repeatedly navigate through a series of web pages to see if any information changes on them, responding appropriately to those changes. On rare occasions a web page appears that requires a response to a form that I'm not sure how to handle. I'm used to seeing HTML forms that look like this one (from the login page)

<form name="loginform" method="post" action="...
<input type="text" class="loginFormText" ID="txtLoginID" name="id" value="">
<input type="password" class="loginFormText" ID="txtPassword" name="pin">

My program responses to this with something like the following:

$response = $browser->post(' ['id' => 'myid', 'pin' => 'mypin']);

The 'action=...' clause in the form tells you what page to post to.

But the web page that I see on rare occasions has HTML that looks like the following:

<form method="post" name="formMain" xmlns:func="urn:extra-functions" xmlns:fldi=" xmlns:str="...
<input type="submit" name="Confirm" value="Confirm" xonClick="return checkForm(formMain)" /></form>

This for has no 'action=...' clause in its specification. So how to I build the arguments to the post method to respond to this form?

Any insights into handling the problem would be much appreciated...
 
In general terms, when there is no action attribute hard scripted in the form tag and that there is a submit button with onclick handler, checkForm('formMain') - I doubt there is no quot/apos enclosing formMain - it usually means this.
[ol][li]The page submits to itself, ie, the page url is what it posts to.[/li]
[li]Or the action is actually dynamically set in the onclick handler (or in the functions it calls upon therefrom). It can happen that the page will post to the url depending on the data inputted in the form field elements, that would make the task even more complicated.. In that case, you should look into the handler itself. In particular, look for the right-hand side of something like:
[tt] document.forms[var].action=[/tt]
[tt]or document.formMain.action=[/tt]
or some more twists to disguise the setting of action attribute.[/li][/ol]
 
How do I get a copy of the CheckForm handler code? I presume that it is somewhere on the HTML page. What language is it written in?

Thanks in advance...
 
It's most likely written in JavaScript. Search the source of the page for it, and then find all the embedded external javascript files for it. It might be a bit trickier to find if they minified or obfuscated their javascript however.

Kirsle.net | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top