Hi,

Instead of putting the values in the JavaScript array...
1. use looping to store the values in hidden fields
2. concatenate all the values with a suitable delimiter and use hidden form
field to store it...
at the servlet end.. retrieve the hidden form field and use StringTokenizer
class to extract the tokens...
Hth,
Manish Bhatnagar

Andras Balogh wrote:

> Hi,
>
> You can't  get the values of a javascript array object from a servlet.
> You have to think a way of putting the values in form objects, only form
> object values are transmited to the servlet.
>
> Hope it helps ,
>
>         Andras.
>
> ----- Original Message -----
> From: Ch.Srinivas Kumar <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, June 06, 2000 10:05 AM
> Subject: Help!!!! how to retrieve multiple values in the doPost method from
> javascript element
>
> > In the below servlet there are three buttons "Submit" whose
> > type=submit,"Reset"whose type=reset,"Add" whose type=button.when the user
> > clicks on "Add" button this button invokes a java-script function which
> > takes the values from the form elements and stores in seperate arrays.I'm
> > using java-script for this and storing them in (javascript)arrays.i used
> > this to avoid refreshing the screen for each new set of values.  Now after
> > he finishes entering all the values he clicks "Submit" which has to take
> all
> > the values from  the arrays and store them in the database.now how do i
> > retrive these values in the doPost method of the same servlet.Please send
> me
> > ur reply as soon as possible.
> >
> >
> > ********************* servlet code****************
> >
> >
> >
> >
> > public class AddMetric extends HttpServlet {
> >
> >
> >
> >
> >  public void init(ServletConfig config) throws ServletException {
> >   super.init(config);
> >  }
> >
> >
> >
> >
> >  public void doGet(HttpServletRequest req,HttpServletResponse res) throws
> > ServletException, IOException {
> >
> >
> >
> >
> >   res.setContentType("text/html");
> >   PrintWriter out = res.getWriter();
> >
> >
> getServletContext().getRequestDispatcher("/servlet/OperatorHeader").include(
> req,res);
> >   out.println("<script language=\"java-script\"
> > src=\"../validation.js\"></script>");
> >   out.println("  <script>");
> >   out.println("  <!--");
> >   out.println("  arr1 = new Array(4);");
> >   out.println("  arr2 = new Array(4);");
> >   out.println("  arr3 = new Array(4);");
> >   out.println("  arr4 = new Array(4);");
> >   out.println("  arr5 = new Array(4);");
> >   out.println("  i=0;");
> >   out.println("  function addmetric() {");
> >   out.println("   if(i>4) {");
> >   out.println("    alert('Sorry now you can add 5 items at a time \n
> Please
> > Submit then you can again');");
> >   out.println("    return false; ");
> >   out.println("   }");
> >   out.println("   arr1[i]=form.metricName.value;");
> >   out.println("   arr2[i]=form.metricDatatype.value;");
> >   out.println("   arr3[i]=form.unit.value;");
> >   out.println("   arr4[i]=form.startValue.value;");
> >   out.println("   arr5[i]=form.endValue.value;");
> >   out.println("   i=i+1;");
> >   out.println("  }");
> >   out.println("  -->");
> >   out.println("  </script>");
> >   out.println("<td width=\"596\" height=\"215\">&nbsp;<p
> > align=\"center\"><strong><small><font face=\"Tahoma\">Add a");
> >   out.println("    new Metrics<small><br>");
> >   out.println("    </small></font></small></strong></p>");
> >   out.println("    <form name=\"form\" method=\"post\"
> > action=\"AddMetric\">");
> >   out.println("      <div align=\"center\"><center><table border=\"0\"
> > cellspacing=\"0\" width=\"355\" height=\"182\"");
> >   out.println("      cellpadding=\"0\">");
> >   out.println("        <tr>");
> >   out.println("          <td width=\"216\" height=\"38\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><strong>Metrics
> > Name</strong></font></small></td>");
> >   out.println("          <td width=\"179\" height=\"38\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><input type=\"text\"");
> >   out.println("          name=\"metricsName\"
> > size=\"18\"></font></small></td>");
> >   out.println("        </tr>");
> >   out.println("        <tr>");
> >   out.println("          <td width=\"216\" height=\"41\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><strong>Metrics");
> >   out.println("          Data&nbsp; Type</strong></font></small></td>");
> >   out.println("          <td width=\"179\" height=\"41\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><input type=\"text\"");
> >   out.println("          name=\"metricsDatatype\" size=\"18\"
> > onfiltered=\"val(MetricsName)\"></font></small></td>");
> >   out.println("        </tr>");
> >   out.println("        <tr>");
> >   out.println("          <td width=\"216\" height=\"36\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><strong>Unit of");
> >   out.println("          Measurement </strong></font></small></td>");
> >   out.println("          <td width=\"179\" height=\"36\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><select
> > name=\"unitOfMeasurement\"");
> >   out.println("          size=\"1\">");
> >   out.println("            <option value=\"Inch\">Inch</option>");
> >   out.println("            <option value=\"Cm\">Cm</option>");
> >   out.println("            <option value=\"Feet\">Feet</option>");
> >   out.println("            <option value=\"Meter\">Meter</option>");
> >   out.println("          </select></font></small></td>");
> >   out.println("        </tr>");
> >   out.println("        <tr>");
> >   out.println("          <td width=\"216\" height=\"31\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><strong>Start
> > Value</strong></font></small></td>");
> >   out.println("          <td width=\"179\" height=\"31\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><input type=\"text\"");
> >   out.println("          name=\"startValue\" size=\"18\"
> > onfiltered=\"val(MetricsDataType)\"></font></small></td>");
> >   out.println("        </tr>");
> >   out.println("        <tr>");
> >   out.println("          <td width=\"216\" height=\"36\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><strong>End
> > Value</strong></font></small></td>");
> >   out.println("          <td width=\"179\" height=\"36\"
> > colspan=\"2\"><small><font face=\"Tahoma\"><input type=\"text\"");
> >   out.println("          name=\"endValue\" size=\"18\"
> > onfiltered=\"val(StartValue)\"></font></small></td>");
> >   out.println("        </tr>");
> >   out.println("        <tr>");
> >   out.println("          <td valign=\"middle\" align=\"center\"
> > width=\"132\"><small><font face=\"Tahoma\"><input");
> >   out.println("          type=\"submit\" value=\"Submit\"
> > name=\"submit\"></font></small></td>");
> >   out.println("          <td valign=\"middle\" align=\"center\"
> > width=\"126\" colspan=\"2\"><small><font face=\"Tahoma\"><input");
> >   out.println("          type=\"reset\" value=\"Reset\"
> > name=\"reset\"></font></small></td>");
> >   out.println("          <td valign=\"middle\" align=\"center\"
> > width=\"120\"><font face=\"Tahoma\"><input type=\"button\"");
> >   out.println("          value=\"Add\" name=\"add\"
> > onfiltered=\"addmetric()\"></font></td>");
> >   out.println("        </tr>");
> >   out.println("      </table>");
> >   out.println("      </center></div>");
> >   out.println("    </form>");
> >   out.println("    </td>    ");
> >
> >
> >
> >
> >
> >
> getServletContext().getRequestDispatcher("/servlet/CopyRightTemplate").inclu
> de(req,res);
> >         out.close();
> >  }
> > }
> >
> >
> >
> >
> > *****************************************************
> >
> >
> >
> >
> >
> > _______________________________________________________
> > Get 100% FREE Internet Access powered by Excite
> > Visit http://freelane.excite.com/freeisp
> >
> >
> ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
Obstacles are things a person sees when he takes his eyes off his goal.

  -E. Joseph Cossman

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to