title: how to get the values from database and get posted automatically into the dynamic textboxes
body: <p>I have a javacript function for adding and removing dynamic textboxes just as shown below<a href="https://i.stack.imgur.com/m6VrW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m6VrW.png" alt="enter image description here"></a></p>
  
  <p>And when i click on save values are saving into database.But my question is when i click on page(which is link) then it should display the values those are in database into these textboxes just as shown below<a href="https://i.stack.imgur.com/jyBeG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jyBeG.png" alt="enter image description here"></a></p>
  
  <p>As shown above,when i click on "Tax Info",it should automatically display the values of the database to the textboxes that are created dynamically.The code for what i had did until now is as shown below.Any idea or solution given will be appreciated.The database table is
  <a href="https://i.stack.imgur.com/suUT0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/suUT0.png" alt="enter image description here"></a></p>
  
  <p>taxInfo.jsp</p>
  
  <pre><code> &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(function () {
      $("#btnAdd").bind("click", function () {
          var div = $("&lt;div /&gt;");
          div.html(GetDynamicTextBox(""));
          $("#TextBoxContainer").append(div);
      });
      $("#btnGet").bind("click", function () {
          var values = "";
          var values1 = "";
          var values2 = "";
          $("input[name=DynamicTextBox]").each(function () {
              values += $(this).val() + "\n";
          });
  
          $("input[name=DynamicTextBox1]").each(function () {
              values1 += $(this).val() + "\n";
          });
  
          $("input[name=DynamicTextBox2]").each(function () {
              values2 += $(this).val() + "\n";
          });
  
          document.location.href ="taxInfoDB.jsp?values=" + values + "&amp;values1=" + values1 + "&amp;values2=" + values2 + "";
      });
      $("body").on("click", ".remove", function () {
          $(this).closest("div").remove();
      });
  });
  function GetDynamicTextBox(value) {
      return '&lt;input name = "DynamicTextBox" type="text" value = "' + value + '" /&gt;&amp;nbsp;' + '&lt;input name = "DynamicTextBox1" type="text" value = "' + value + '" /&gt;&amp;nbsp;' + '&lt;input name = "DynamicTextBox2" type="text" value = "' + value + '" /&gt;&amp;nbsp;' +
              '&lt;input type="button" value="Remove" class="remove" /&gt;'
  }
  &lt;/script&gt;
  
          &lt;/div&gt;
       &lt;div id="divMenu"&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a class="current" href="/SalesPropeller/Admin/Profile/Phome.jsp"&gt;Profile&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/SalesPropeller/Admin/ManageUser/Mhome.jsp"&gt;Manage User&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Lead/home.jsp"&gt;Lead Management&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Purchase/Puhome.jsp"&gt;Purchase&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Sales/Shome.jsp"&gt;Sales&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Payroll/Phome.jsp"&gt;PayRoll&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/SalesPropeller/Admin/CustomerComplain/chome.jsp"&gt;Customer Services&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
          &lt;div id="divLeft"&gt;
              &lt;div id="divWelcome"&gt;
                  Welcome&lt;br /&gt; &lt;b&gt;${sessionScope.name}&lt;/b&gt;
              &lt;/div&gt;
              &lt;div id="divLeftTop"&gt;
                  &lt;img
                      src="/SalesPropeller/Profile/displayblob.jsp"
                      height="160" width="140" /&gt;
              &lt;/div&gt;
              &lt;hr /&gt;
              &lt;ul id="MenuBar1" class="MenuBarHorizontal"&gt;
                  &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Profile/Phome.jsp"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Profile/profile.jsp"&gt;Admin
                          Profile&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Profile/addCompanyProfile.jsp"&gt;Company Profile&lt;/a&gt;&lt;/li&gt;
  
                  &lt;li&gt;&lt;a class="current" href="/SalesPropeller/Admin/Profile/taxInfo.jsp"&gt;Tax Info&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a class="MenuBarItemSubmenu"
                      href="/SalesPropeller/Admin/Profile/message.jsp"&gt;Messages&lt;/a&gt;
                      &lt;ul&gt;
                          &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Profile/compose.jsp"&gt;Compose
                                  New&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Profile/inbox.jsp"&gt;Inbox&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="/SalesPropeller/Admin/Profile/outbox.jsp"&gt;Sent Messages&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="/SalesPropeller/logout.jsp"&gt;Logout&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
              &lt;script type="text/javascript"&gt;
                      &lt;!--
                      var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
                      //--&gt;
                  &lt;/script&gt;
  
          &lt;/div&gt;
          &lt;div id="divRight"&gt;
              &lt;br /&gt;
  
  
                   &lt;form name="form"  method="post"&gt;
              &lt;div align="center"&gt;
                  &lt;input id="btnAdd" type="button" value="Add" /&gt;
  &lt;br /&gt;&lt;br/&gt;
  &lt;b style="padding-right:100px"&gt;Name of the Tax&lt;/b&gt; &lt;b style="padding-right:100px"&gt;Value&lt;/b&gt; &lt;b style="padding-right:100px"&gt;TaxGroup&lt;/b&gt;  
  &lt;div id="TextBoxContainer"&gt;
      &lt;!--Textboxes will be added here --&gt;
  &lt;/div&gt;
  &lt;br /&gt;
  &lt;input id="btnGet" type="button" value="Save" /&gt;
  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>taxInfoDB.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ page import="java.io.*"%&gt;
  &lt;%@ page import="java.sql.*"%&gt;
  &lt;%@ page import="com.model.*"%&gt;
  &lt;%@ page import="java.util.*"%&gt;
  &lt;%@ page import="java.text.DecimalFormat"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Tax Saving Database&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
  String values = request.getParameter("values");
  String values1 = request.getParameter("values1");
  String values2 = request.getParameter("values2");
  System.out.println("values are:"+values);
  System.out.println("values1 are:" +values1);
  System.out.println("values2 are:" +values2);
  try{
      DBConnect db =new DBConnect();
      Connection con = db.getCon();
      String sql ="insert IGNORE_DUP_KEY = ON into marketing_database.tax_info (TaxGroup,Name,Value) values (?,?,?);";
      PreparedStatement ps = con.prepareStatement(sql);
      ps.setString(1, values2);
      ps.setString(2, values);
      ps.setString(3, values1);
      ps.executeUpdate();
      con.close();
      ps.close();
  
          }
          catch(SQLException ex){
      ex.printStackTrace();
          }
  
  response.sendRedirect("taxInfo.jsp");
  %&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>