Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: submitting nameless form using WWW::mechanize

by opensourcer (Monk)
on Jun 18, 2008 at 06:52 UTC ( #692638=note: print w/replies, xml ) Need Help??

in reply to Re: submitting nameless form using WWW::mechanize
in thread submitting nameless form using WWW::mechanize

it's a nameless form <form> .... </form>
i have checked for form number using $mech->forms()
which displays nothing .
  • Comment on Re^2: submitting nameless form using WWW::mechanize

Replies are listed 'Best First'.
Re: submitting nameless form using WWW::mechanize
by b10m (Vicar) on Jun 18, 2008 at 07:37 UTC
    "i have checked for form number using $mech->forms() which displays nothing."

    This might be due to JavaScript generated forms, which are really a pain in the ***. Try to look at the source through your preferred webbrowser and see what's going on there. If the form is there, without a name, indeed simply count them (and don't forget hidden forms ;-)

      The following is the code inside the html.
      <body onLoad="getSearch();getUserSettings();callonLoad();"> <form> <p>&nbsp;</p> <table width="775" border="0" align="center" cellpadding="0" cellsp +acing="0" bgcolor="#FFFFFF"> <tr> <td><img src="/userportal/pages/usermedia/inventumtest.1/images/ +top.jpg" width="775" height="111"></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding= +"0"> <tr> <td width="33%"><div align="center"><img src="/userportal/ +pages/usermedia/inventumtest.1/images/lady.jpg" width="161" height="2 +00"></div></td> <td><table width="240" height="150" border="0" align="cen +ter" cellpadding="0" cellspacing="0" background="/userportal/pages/us +ermedia/inventumtest.1/images/TableBG.jpg"> <tr> <td valign="top"><table width="100%" height="100%" bo +rder="0" cellpadding="1" cellspacing="1"> <tr> <td colspan="2" class="loginBoxMainStyle"><div a +lign="left">&nbsp;Login</div></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="right" +>Service Type :</div></td> <td> <select name="type" class="loginBoxTextStyl +e"><option value="1">Check Account Details</option></select> </td> </tr> <tr> <td class="loginBoxTextStyle"><div align="right" +>Login ID : </div></td> <td><input type="text" name="username" value="" +class="loginBoxFormTextStyle"></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="right" +>Password : </div></td> <td><input type="password" name="password" value +="" class="loginBoxFormTextStyle"></td> </tr> <tr> <td colspan="2" class="loginBoxTextStyle"><div a +lign="center"> <input type="checkbox" id="rememberme" name="rememberme" >Remember Me +</div></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="button" value="Login" class="loginBoxTextStyle" onclick=" +return savesettings();"/> </div></td> </tr> </table></td> </tr> </table></td> <td width="33%"><table width="100%" border="0" cellspacin +g="0" cellpadding="0"> <tr id="popup" style="display:none"> <td><table width="240" height="150" border="0" align= +"center" cellpadding="0" cellspacing="0" background="/userportal/page +s/usermedia/inventumtest.1/images/TableBG.jpg"> <tr> <td valign="top"><table width="100%" height="100%" + border="0" cellpadding="1" cellspacing="1"> <tr> <td colspan="2" class="loginBoxMainStyle"><d +iv align="left">&nbsp;Session Details </div></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght">Start Time : </div></td> <td><INPUT TYPE=TEXT NAME="start" SIZE=17 va +lue="18/06/2008 09:24:55" readonly></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght">Duration : </div></td> <td><INPUT TYPE=TEXT NAME="duration" SIZE=17 + readonly></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght">Balance :</div></td> <td><INPUT TYPE=TEXT size="17" NAME="subs" v +alue="" readonly></td> </tr> <tr> <td class="loginBoxTextStyle" colspan="2"> <b>Your Internet Session Active</b> &nbsp;&nbsp;<a href="/userportal/"> +Click Here To Logout</a></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght"></div></td> <td>&nbsp;</td> </tr> </table></td> </tr> </table></td> </tr> </table> </td> </tr> </table></td> </tr> <tr> <td><img src="/userportal/pages/usermedia/inventumtest.1/images/ +inventlogo.png" width="140" height="43"></td> </tr> <tr> <td bgcolor="#336699"><div align="center" class="loginBoxTextSty +le"><font color="#ffffff">Powered by SSG Unify <a href=""><font color="#ffffcc"> (c) Inventum Technologies Pvt. Ltd. +</font></a></font></div></td> </tr> </table> <INPUT TYPE=hidden NAME="clock"> </form>

      I have tried every number in the block (1..x) but ...
      script says: There is no form numbered 4 at line 45 Died at /usr/lib/perl5/site_perl/5.8.8/WWW/ line 1724.
        There is no action for the <form> that you're showing us (without which it can't "do" anything, nor does <input type="button" value="Login" class="loginBoxTextStyle" onclick="return savesettings();"/> clarify much other than to make it clear you're dealing with a js function.

        Is it possible that the page is broken (even when visited with your browser), or that you missed something in the .html?

        Update: "can't" above is badly stated; even without an action, use of <form> and subordinate elements will effect rendering. But worse, even though the OP's code update made it clear (duh! even to me!) that the issue was at least in part a js issue, I didn't consider that in the flat "can't." Bah! And apologies for careless thought.

        However, parv's question below about the default action (when none is specified) sent me checking the w3c's html 4.01 specification. I may still have missed something, and, as always, it's well to remember that browser-writers sometimes :-) build browsers that are not fully conformant.

        Nonetheless, what follows is what I found:

        <!ATTLIST FORM
        • %attrs;               -- %coreattrs, %i18n, %events --
        • action %URI; #REQUIRED -- server-side form handler --
        • ...
        • onsubmit %Script; #IMPLIED -- the form was submitted --


        action = uri CT
          This attribute specifies a form processing agent. User agent behavior for a value other than an HTTP URI is undefined.

        I found only one instance of "<form"; so form(1) /should/ have worked.
Re^3: submitting nameless form using WWW::mechanize
by Corion (Pope) on Jun 18, 2008 at 06:57 UTC

    Every form has a number. You start counting by 1 and increment the form number whenever a new form starts. Just try it:

    $mech->form_number(3); # selects the third form on the page $mech->submit; # submits the third form
Re^3: submitting nameless form using WWW::mechanize
by Anonymous Monk on Jun 18, 2008 at 06:57 UTC
    Count, you know 1, 2, 3, 4, 5 , 6, 7, 8, 9, 10, them select the form 3rd form on the page

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://692638]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2017-08-19 14:14 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (311 votes). Check out past polls.