in reply to Re^3: WIN32::IE::Mechanize - can't follow link - JavaScript involved
in thread WIN32::IE::Mechanize - can't follow link - JavaScript involved

Okay, I followed the JavaScipt script that looked like it would be the right one and I think it is. Here is the content. You can see that it includes the JSubmitForm() function call that appears in the "go2" button (that isn't a button!?).

browserName = navigator.appName; browserVer = parseInt(navigator.appVersion); if ((browserName == "Netscape" && browserVer >= 3) || (browserName == "Microsoft Internet Explorer" && browserVer >= + 4)) { version = "n3"; } else { version = "n2"; } if (version == "n3") { go_on = new Image; go_on.src = "/IAPD/Images/go_on.gif"; go_off = new Image; go_off.src = "/IAPD/Images/go_off.gif"; go2_on = new Image; go2_on.src = "/IAPD/Images/go_on.gif"; go2_off = new Image; go2_off.src = "/IAPD/Images/go_off.gif"; go3_on = new Image; go3_on.src = "/IAPD/Images/go_on.gif"; go3_off = new Image; go3_off.src = "/IAPD/Images/go_off.gif"; } /********************************************************************* +********* * Function: * JImgAct * * Purpose: * This function is called to activate an image. * ********************************************************************** +********/ function JImgAct(imgName) { if (version == "n3") { imgOn = eval(imgName + "_on.src"); document [imgName].src = imgOn; } } /********************************************************************* +********* * Function: * JImgInact * * Purpose: * This function is called to inactivate an image. * ********************************************************************** +********/ function JImgInact(imgName) { if (version == "n3") { imgOff = eval(imgName + "_off.src"); document [imgName].src = imgOff; } } function JSubmitForm() { document.Content.Name.value = document.Search1.Name.value; document.Content.CrdNumber.value = document.Search2.CrdNumber.valu +e; document.Content.SecNumber.value = document.Search3.SecNumber.valu +e; if (eval("document.Search1.SearchType[0].checked") == true) { document.Content.SearchType.value = 1; } if (eval("document.Search1.SearchType[1].checked") == true) { document.Content.SearchType.value = 2; } if (eval("document.Search1.SearchType[2].checked") == true) { document.Content.SearchType.value = 3; } if (eval("document.Search4.NumRows[0].selected") == true) { document.Content.NumRows.value = document.Search4.NumRows[0].v +alue; } if (eval("document.Search4.NumRows[1].selected") == true) { document.Content.NumRows.value = document.Search4.NumRows[1].v +alue; } if (eval("document.Search4.NumRows[2].selected") == true) { document.Content.NumRows.value = document.Search4.NumRows[2].v +alue; } if (eval("document.Search4.NumRows[3].selected") == true) { document.Content.NumRows.value = document.Search4.NumRows[3].v +alue; } document.Content.submit(); return false; }

With the JS code in hand, how do I attack my original problem of getting the form to submit? Thanks!

  • Comment on Re^4: WIN32::IE::Mechanize - can't follow link - JavaScript involved
  • Download Code

Replies are listed 'Best First'.
Re^5: WIN32::IE::Mechanize - can't follow link - JavaScript involved
by psini (Deacon) on May 22, 2008 at 19:01 UTC

    Well, when you click (any)one of the "go" buttons, the jSubmitForm function populate the hidden fields of this form:

    <form name="Content" method="Post"> <input type="hidden" name="LinkPage" value=""> <input type="hidden" name="PageType" value="Search"> <input type="hidden" name="ORG_PK" value="000"> <input type="hidden" name="STATE_CD" value=""> <input type="hidden" name="Name" value=""> <input type="hidden" name="SearchType" value=""> <input type="hidden" name="CrdNumber" value=""> <input type="hidden" name="SecNumber" value=""> <input type="hidden" name="NumRows" value=""> <input type="hidden" name="Save" value="IAPDSearch"> </form>

    and submit it to the site.

    All you have to do is to prepare a POST statement with the fields correctly populated and submit it directly.

    I advise you to see the CGI module, with that you can do it with little more than 4 lines of perl.

    Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

      BINGO! Worked like a charm (using post). Thanks for your patience and all your help!