Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    99
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question assign DB Values to HTML textbox in JSP

    I am trying to get the database values saved from form into Textbox . The values are loaded whenever the form is loaded. I have written a example code what I am doing below. I have 5 rows of textboxes. I have written the below code that get the values from database. But my knowledge is limited about getting those five rows of values to the five rows of textboxes either using JSP or JAVAScript. Tried searching online but didn't fine related answer. Any help will be appreciated. Thank you.


    Code:
    <body>
    <% 
    String processVal = "SELECT  * FROM  NETWORK_ACCESS WHERE PRD_ID=?";
     PreparedStatement pst = conn.prepareStatement(processVal);
     pst.setString(1, ProcID);
     ResultSet rsProcess=pst.executeQuery();
    
     while(rsProcess.next())
        {
    
    SIP=rs.getString(2);
    DIP=rs.getString(3);
    SP=rs.getString(4);
    SD=rs.getString(5);
    ED=rs.getString(6); 
        }
     %>
    
    
    <table>
    <tr>    
      <th>Sl.No</th>
      <th>SIP</th>
      <th>DIP</th>
      <th>SP</th>
      <th>Start Date</th>
      <th>END Date</th>
      </tr>
     <tr>
     <td style="align:center"> 1 </td>
    <td><input type="text" name="name" id="id" size="20"> </td>
     <td><input type="text" name="name1" id="id1" size="20"> </td>
     <td><input type="text" name="name2" id="id2" size="20"> </td>
     <td><input type="text" name="name3" id="id3" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id4" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
      <tr>
     <td style="align:center"> <label> 2 </label> </td>
     <td><input type="text" name="name" id="id5" size="20"> </td>
     <td><input type="text" name="name1" id="id6" size="20"> </td>
     <td><input type="text" name="name2" id="id7" size="20"> </td>
     <td><input type="text" name="name3" id="id8" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id9" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
      <tr>
      <td> <label> 3 </label> </td>
     <td><input type="text" name="name" id="id10" size="20"> </td>
     <td><input type="text" name="name1" id="id11" size="20"> </td>
     <td><input type="text" name="name2" id="id12" size="20"> </td>
     <td><input type="text" name="name3" id="id13" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id14" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
      <tr>
      <td> <label>4 </label> </td>
     <td><input type="text" name="name" id="id15" size="20"> </td>
     <td><input type="text" name="name1" id="id15" size="20"> </td>
     <td><input type="text" name="name2" id="id16" size="20"> </td>
     <td><input type="text" name="name3" id="id17" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id18" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
        <tr>
       <td> <label>5 </label> </td>
     <td><input type="text" name="name" id="id19" size="20"> </td>
     <td><input type="text" name="name1" id="id20" size="20"> </td>
     <td><input type="text" name="name2" id="id21" size="20"> </td>
     <td><input type="text" name="name3" id="id22" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id23" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
    </table>

  • #2
    New Coder
    Join Date
    Jan 2012
    Posts
    96
    Thanks
    1
    Thanked 13 Times in 13 Posts
    Code:
    <body>
    <% 
    String processVal = "SELECT  * FROM  NETWORK_ACCESS WHERE PRD_ID=?";
     PreparedStatement pst = conn.prepareStatement(processVal);
     pst.setString(1, ProcID);
     ResultSet rsProcess=pst.executeQuery();
    
    String SIP;
    String DIP;
    String SP;
    String SD;
    String ED;
    
     while(rsProcess.next())
        {
    
    SIP=rs.getString(2);
    DIP=rs.getString(3);
    SP=rs.getString(4);
    SD=rs.getString(5);
    ED=rs.getString(6); 
        }
     %>
    
    
    <table>
    <tr>    
      <th>Sl.No</th>
      <th>SIP</th>
      <th>DIP</th>
      <th>SP</th>
      <th>Start Date</th>
      <th>END Date</th>
      </tr>
     <tr>
     <td style="align:center"> 1 </td>
    <td><input type="text" name="name" id="id" size="20" value="${SIP}"> </td>
     <td><input type="text" name="name1" id="id1" size="20" value="${DIP}"> </td>
     <td><input type="text" name="name2" id="id2" size="20" value="${SP}"> </td>
     <td><input type="text" name="name3" id="id3" size="15" value="${SD}"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id4" size="15" value="${ED}"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
      <tr>
     <td style="align:center"> <label> 2 </label> </td>
     <td><input type="text" name="name" id="id5" size="20"> </td>
     <td><input type="text" name="name1" id="id6" size="20"> </td>
     <td><input type="text" name="name2" id="id7" size="20"> </td>
     <td><input type="text" name="name3" id="id8" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id9" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
      <tr>
      <td> <label> 3 </label> </td>
     <td><input type="text" name="name" id="id10" size="20"> </td>
     <td><input type="text" name="name1" id="id11" size="20"> </td>
     <td><input type="text" name="name2" id="id12" size="20"> </td>
     <td><input type="text" name="name3" id="id13" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id14" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
      <tr>
      <td> <label>4 </label> </td>
     <td><input type="text" name="name" id="id15" size="20"> </td>
     <td><input type="text" name="name1" id="id15" size="20"> </td>
     <td><input type="text" name="name2" id="id16" size="20"> </td>
     <td><input type="text" name="name3" id="id17" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id18" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
        <tr>
       <td> <label>5 </label> </td>
     <td><input type="text" name="name" id="id19" size="20"> </td>
     <td><input type="text" name="name1" id="id20" size="20"> </td>
     <td><input type="text" name="name2" id="id21" size="20"> </td>
     <td><input type="text" name="name3" id="id22" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
     <td><input type="text" name="name4" id="id23" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
     </tr>
    </table>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •