Hi,
There are these struts tags in my jsp. I need to write a javascript function so 
that when a button addrow is clicked a new row with
these 2 dropdown lists(tables, columns) is displayed. how to add a row with 
javascript function.
the second dropdown options depend on the table selected in the first dropdown. 
how do I write a onchange function to get the columns of the table selected.
I have the javascript function to get tables and columns. 

 <nested:iterate id="conversion" name="updateForm" property="rowSet.rows" 
type="com.net.menuentry">
                                  <TR class=tblcellwhite>
                                  <TD height=21>
                                    <nested:select name="rows" 
property="repColumn.repTable.repTableId">
                                      <logic:iterate id="repTable" 
name="updateForm" property="tableList" type="com.net.RepTable">
                                        <html:option 
value="<%=repTable.getRepTableId().toString()%>"><%=repTable.getDisplayName()%></html:option>
                                      </logic:iterate>
                                    </nested:select>
                                  </TD>
                                  <TD>
                                    <nested:select name="rows" 
property="repColumn.repColumnId">
                                      <logic:iterate id="repTable" 
name="updateForm" property="tableList" type="com.cnet.RepTable">
                                        <nested:equal name="conversion" 
property="repositoryColumn.repositoryTable.repTableId" 
value="<%=repTable.getRepTableId().toString()%>">
                                          <nested:iterate id="repColumn" 
name="repTable" property="repColumns" type="com.cnet.RepColumn">
                                            <html:option 
value="<%=repColumn.getRepColumnId().toString()%>"><%=repColumn.getDisplayName()%></html:option>
                                          </nested:iterate>
                                        </nested:equal>
                                      </logic:iterate>
                                    </nested:select>
                                  </TD>

function getTables() {
  var tables = [ 
 <%
  List list = updateForm.getTableList();
        if (list != null) {
          int tableCount = list.size();
          for(int i=0; i<tableCount; i++) {
            RepTable table = (RepTable) list.get(i);
            out.write("\"" + table.getDisplayName() + "\"");
            if (i<tableCount-1) {
              out.write(" ,");
            }
          }
        }
    %>
  ];
  return tables;
}
function getColumnList(tableIndex) {
  var columnList = [
 <%
        if (list != null) {
          int tableCount = list.size();
          for(int i=0; i<tableCount; i++) {
            RepTable table = (RepTable) list.get(i);
            Set columns = table.getRepColumns();
            if (columns != null) {
              out.write("[ ");
              int columnCount = columns.size();
              int col = 0;
              for (Iterator iter=columns.iterator(); iter.hasNext();) {
                RepColumn column = (RepColumn) iter.next();
                out.write("\"" + column.getDisplayName() + "\"");
                if (col<columnCount-1) {
                  out.write(" ,");
                }
                col++;
              }
              out.write(" ]");
              if (i<tableCount-1) {
                out.write(",\r\n");
              }
           }
          }
        }
    %>
  ];
  return columnList[tableIndex];
}
 
 
thanks.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to