简体   繁体   中英

Getting data from the dynamically updated fields from JSP to Servlet

<li>
  <div id="time"style="float: left;">
    <div id="fromtime" style="float: left;">
      <span class="fromtime">From</span><br><br>
      <input type="text" size="7" class="from_time" name='FromTime'/>
    </div>
    <div id="totime" style="float: left;">
      <span class="totime">To</span><br><br>
      <input type="text" size="7" class="to_time" name='ToTime'/>
    </div>
    <div style="clear:both;">
    </div>
  </div>
</li>

In this portion of my form, I need to take input from the user for 'FromTime' and 'ToTime'.

On entering these values, I dynamically create another li (using jquery) just like above to have another 'FromTime' and 'ToTime' and goes on. How can I retrieve all these 'FromTime' and 'ToTime' in my servlet? When I use request.getParameter("FromTime") and request.getParameter("ToTime") , I get only the first li values.

使用getParameterValues()获取具有给定名称的所有值的数组。

Try using getParameterValues(String) instead of getParameter. If that doesn't work, just number the parameter values in your javascript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM