Pete - 2005-09-23

Hi
I'm trying to set the value of a password field in a form. The form is defined as below:

<form name="myForm" method="post" action="ommitted">
.....
<INPUT type="password" size="20", maxlength="20" name="password" value="" TABINDEX="2">
</form>

It has a javascript function as below:

function checkLogin()
{
    if( document.myForm.userId.value == "" )  {
          alert( "Please enter a valid username" );
          return false;
    }
 
    if( document.myForm.password.value == "" )  {
          alert( "Please enter a valid password" );
          return false;
    }

    document.myForm.submit();
}

If I get the form and try:

                    form.setParameter("userId", "username");
                    form.setParameter("password", "pwd");

com.meterware.httpunit.WebForm$NoSuchParameterException: No parameter named 'password' is defined in the form

If I try:

                    Scriptable s = form.getScriptableObject();   
                    s.setParameterValue("userId", "user"); 
                    s.setParameterValue("password", "pwd");

I get
java.lang.ArrayIndexOutOfBoundsException: 0

If I print the form parameter names with:

                    String [] names = form.getParameterNames();
                   
                    for (int j = 0; j < names.length; j++) {
                        System.out.println(names[j]);
                    }

the password field is not present. I must be missing something so if anyone can spot it I'd be most grateful.

Thanks