Does anybody know how to set multiple check boxes in the same form that all have the same name? When I use setParameter on a single item, it works great.
But when there are several ckeckboxes with the same name but different values, I am having problems. When I set the second checkbox, it overwrites the value of the first. This continues and only the last one gets submitted. Check this out:
Does anybody know how to set multiple check boxes in the same form that all have the same name? When I use setParameter on a single item, it works great.
<form>
<input type="checkbox" name="name" value="value">
</form>
form.setParameter( "name", "value" );
But when there are several ckeckboxes with the same name but different values, I am having problems. When I set the second checkbox, it overwrites the value of the first. This continues and only the last one gets submitted. Check this out:
<form>
<input type="checkbox" name="name" value="value1">
<input type="checkbox" name="name" value="value2">
<input type="checkbox" name="name" value="value3">
<input type="checkbox" name="name" value="value4">
</form>
form.setParameter( "name", "value1" );
form.setParameter( "name", "value2" );
form.setParameter( "name", "value3" );
form.setParameter( "name", "value4" );
Only value4 is set.
Unfortunately this is behaving as one would expect. Is there a way to handle this type of form with HttpUnit?
Set them all at once:
form.setParameter( "name", new String[] { "value1", "value3" } );