<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%
      java.lang.String[] names = (java.lang.String[])request.getSession().getAttribute("prefs");
 %>

<html>
<head>
  <title>PDA-Application Profile Page</title>
  <script type="text/javascript">
    function saveProfile()
    {
      valueString = "";
      for (i = 0; i < 4; i++)
      {
        fieldName = "field" + i;
        v = document.getElementsByName(fieldName)[0].value;
        valueString += v + ",";
      }
      document.forms[0].elements[0].value = valueString;
      document.forms[0].submit();
    }

    function cancel()
    {
       location.href="Menu.jsp";
    }
  </script>
</head>
  <body>

    <center>
     <h1>Please enter your new Preferences</h1>
     <html:errors/><p>
      <table border="0">
         <tr><th>Name</th><th>Value</th></tr>
         <% 
             for (int i = 0; i < names.length; i++)
             {
                java.lang.String name = names[i];
                %><tr><td><b><%= name %></b></td><td><input type="text" name="field<%= i %>" size="5" maxlength="5"></td></tr><%
             }
          %>
         <tr></tr>
      </table>
    </center>

  <html:form action="submitProfile.do">
    <html:hidden name="profileForm" property="profileString"/>
  </html:form>
   
  <p>
  <center>
    <input type="button" value="Submit" onClick="saveProfile()"/>
    <input type="button" value="Cancel" onClick="cancel()"/>  
  </center>
 
  </body>
</html>
