Results 1 to 1 of 1
- 12-21-2010, 06:03 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 3
- Rep Power
- 0
set gender and selected combobox value
How to set selected radio button from the database record?
because i want to modify the record from the database and set it to the html form to let the user to update the personal information.
my code is like this, and i need help on the radio button and combo box.
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h2>Update Student</h2>");
String id;
id = request.getParameter("id");
if(id.compareTo("")==0){
out.println("Please fill in the student ID.");}
else{
try{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:StudentDS";
String sql = "SELECT * FROM Student "+
"WHERE StudentID = ?";
Class.forName(driver);
Connection con = DriverManager.getConnection(url);
PreparedStatement stm = con.prepareStatement(sql);
stm.setString(1, id);
ResultSet rs = stm.executeQuery();
String name = "";
String ic = "";
if (rs.next()){
id = rs.getString("StudentID");
name = rs.getString("StudentName");
ic = rs.getString("ICNumber");
}
out.printf(
"<form action='UpdateStudent' method='post'>"+
"<table>"+
" <tr>"+
" <td>Student ID :</td>"+
" <td>%s</td>"+
" </tr>"+
" <tr>"+
" <td>Student Name :</td>"+
" <td><input type='text' name='name' value='%s'/></td>"+
" </tr>"+
" <tr>"+
" <td>Ic Number :</td>"+
" <td><input type='text' name='ic' value='%s'/></td>"+
" </tr>"+
"</table>"+
"<input type='submit' value='Update'/>"+
"<input type='reset' value='Reset'/>"+
"<input type='hidden' name='id' value='%s'/>"+
"</form>",
id,name,ic,id
);
rs.close();
stm.close();
con.close();
Similar Threads
-
JButton selected
By sky in forum AWT / SwingReplies: 6Last Post: 12-05-2009, 09:36 PM -
JTable Gridline in selected row
By arubin in forum AWT / SwingReplies: 11Last Post: 11-24-2009, 07:05 PM -
Need Help combobox
By kwink in forum AWT / SwingReplies: 3Last Post: 03-21-2009, 10:05 AM -
JTable problem with getting ROW selected
By nadia in forum Advanced JavaReplies: 2Last Post: 01-13-2009, 05:57 PM -
combobox
By chandu.v in forum New To JavaReplies: 2Last Post: 07-02-2008, 08:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks