Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple arrays of form fields question.

Status
Not open for further replies.

Exie

Programmer
Sep 3, 2003
156
AU
Hi,

I have a form which asks the user to fill out 2 fields for each customer. I dont know how many customers there will be, an array list is populated before hand and I'm using a logic:iterate to create a form listing each one.

The HTML looks a bit like:
Code:
<form name="SSCMHomeForm" method="post" action="/sscm/SSCMHomeAction.do">				
  <TR> 
    <!--	CheckBox 	-->
    <TD width="20">
      <input type="checkbox" name="refChecked" value="653"/>
    </TD>
    <TD width="100">
      <input type="text" name="comment"/>
    </TD>
  </TR>
  <TR> 
    <!--	CheckBox 	-->
    <TD width="20">
      <input type="checkbox" name="refChecked" value="635"/>
    </TD>
    <TD width="100">
      <input type="text" name="comment"/>
    </TD>
  </TR>
</form>

The form looks a little like:
Code:
public class SSCMHomeForm extends ValidatorForm {
	
	private String[] refChecked = null;
	private String[] comment = null;

	public String[] getRefChecked() {
		return refChecked;
	}
	public void setRefChecked(String[] strings) {
		refChecked = strings;
	}

	public String[] getComment() {
		return comment;
	}
	public void setComment(String[] strings) {
		comment = strings;
	}
	
}

My question is, how will I know which element in my [blue]comment[/blue] string array matches with which [blue]refChecked[/blue] value ?

Is there a better way to keep these in sync, so I can be confident when I'm processing my form, that I'm matching the right comment with the right refChecked value.

Could I perhaps use a 3d array in my java form ? if so, how would I reference this in my html ?
 
Try the following:
1. on jsp, use <html:iterate> within the <form>
2. in the form, add getXXXXX(int index) methods, e.g.
public String getComment(int index) {
return comment[index];
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top