Sign in to follow this  
Followers 0
exploitz

Fill form in a frame

3 posts in this topic

Hi guys, I've got a multiframed webpage and I need to fill in some information inside a form on the first frame.

heres the source code for frame one:

<html>
<head>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<style>

    TD {font-family: arial }

</style>
<script type="text/Javascript">
<!--
function isAlpha( keynum ) { return ( keynum <= 90 & keynum >= 65 ) | ( keynum <= 122 & keynum >= 97 ); }
function isNumeric( keynum ) { return ( keynum <= 57 & keynum >= 48 ); }

function isNavigation( keynum ) {
    return ( keynum <= 40 & keynum >= 37 ) | keynum == 8 | keynum == 46 | keynum == 36 | keynum == 35 | keynum == 9;
}

function idKeyPress( e ) {
    var result = false;
    var keynum = e.which ? e.which : e.keyCode;
    if( isNumeric( keynum ) | isNavigation( keynum ) ) {
        result = true;
    } else if( keynum == 13 ) {
        result = validateID( );
    }
    return result;
}

function snKeyPress( e ) {
    var result = false;
    var keynum = e.which ? e.which : e.keyCode;
    if( isAlpha( keynum ) | isNavigation( keynum ) ) {
        result = true;
    } else if( keynum == 13 ) {
        result = validateSurname( );
    }
    return result;
}

function uidKeyPress( e ) {
    var result = false;
    var keynum = e.which ? e.which : e.keyCode;
    if( isAlpha( keynum ) | isNumeric( keynum ) | isNavigation( keynum ) ) {
        result = true;
    } else if( keynum == 13 ) {
        result = validateUsername( );
    }
    return result;
}

function validateID( ) {
    var error = "";
    var re = new RegExp( "^[0-9]{9,10}$" );
    var m = re.exec( document.sidform.sid.value );
    if( m == null )
        error += "You must enter a valid student ID or SSN with 9 decimal digits.  E.g: 123456789.\n";
    if( error != "" ) {
        alert( "The following problems are wrong with your request:\n" + error );
        return false;
    } else {
        sidform.submit( );
        return true;
    }
}

function validateSurname( ) {
    var error = "";
    var re = new RegExp( "^[a-zA-Z][a-zA-Z]*$" );
    var m = re.exec( document.snform.sn.value );
    if( m == null )
        error += "You must enter a surname for searching: only upper and lowercase characters allowed.\n";
    if( error != "" ) {
        alert( "The following problems are wrong with your request:\n" + error );
        return false;
    } else {
        snform.submit( );
        return true;
    }
}

function validateUsername( ) {
    var error = "";
    var re = new RegExp( "^[a-zA-Z0-9][a-zA-Z0-9]+$" );
    var m = re.exec( document.uidform.uid.value );
    if( m == null )
        error += "You must enter a userid for searching: only alphanumeric characters allowed.\n";
    if( error != "" ) {
        alert( "The following problems are wrong with your request:\n" + error );
        return false;
    } else {
        uidform.submit( );
        return true;
    }
}

// -->
</script>
</head>
<body> 
<body bgcolor="#cecece">
<strong>UTT Person Lookup Tool</strong><hr>
<a href="main.html" target="body">Home</a>
<table border=2>
    <tr bgcolor=LightSteelBlue>
        <td>Search by ID</td>
    </tr>
    <tr>
        <td>
            <form target="body" action="lookup.php" method="POST" name="sidform">
            <input type="hidden" name="m" value="sid">
            <input type="text" name="sid" size=10 maxlength=10 onkeypress="return idKeyPress( event );">
            <input type="button" value="Search" onclick="return validateID( );">
            </form>
        </td>
    </tr>
    <tr bgcolor=LightSteelBlue>
        <td>Search by Surname</td>
    </tr>
    <tr>
        <td>
            <form target="body" action="lookup.php" method="POST" name="snform">
            <input type="hidden" name="m" value="sn">
            <input type="text" name="sn" size=10 maxlength=24 onkeypress="return snKeyPress( event );">
            <input type="button" value="Search" onclick="return validateSurname( );">
            </form>
        </td>
    </tr>
    <tr bgcolor=LightSteelBlue>
        <td>Search by Username</td>
    </tr>
    <tr>
        <td>
            <form target="body" action="lookup.php" method="POST" name="uidform">
            <input type="hidden" name="m" value="username">
            <input type="text" name="uid" size=10 maxlength=24 onkeypress="return uidKeyPress( event );">
            <input type="button" value="Search" onclick="return validateUsername( );">
            </form>
        </td>
    </tr>
    </form>
</table>
Author(s): Tim Crouch, Justin Summerlin
</body>
</html>

Here is my code:

$oIE = _IEAttach ("webpage", "url")
    WinActivate("webpage")
    $oFrame = _IEFrameGetCollection ($oIE, 1)
    $oForm = _IEFormElementGetCollection($oFrame, 0)
    $oSID = _IEGetObjByName($oFrame,"sid")
    _IEFormElementSetValue($oSID, GUICtrlRead($studentIDBox))
    _IEFormSubmit($oForm)

It fills in the box with the ID number, however I cannot get the form to submit.

Please help.

Thanks,

Chase

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe try something like this?

#include <IE.au3>
$oIE = _IEAttach ("webpage", "url")
$oFrame = _IEFrameGetCollection ($oIE, 1)
$oForm = _IEFormElementGetCollection($oFrame, 0)
$oSID = _IEGetObjByName($oFrame,"sid")
_IEFormElementSetValue($oSID, GUICtrlRead($studentIDBox))
 $oInputs = _IETagNameGetCollection($oForm, "input")
For $oInput In $oInputs
    If $oInput.type = "button" Then
        _IEAction($oInput, "click")
        _IELoadWait($oIE)
        ExitLoop
    EndIf
Next
Edited by exodius

Share this post


Link to post
Share on other sites

I finally got it. It was an error in my code...

My mistake!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0