This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Building HTML Controls On The Fly

 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create some HTML TEXT controls in a loop that will display the contents of a result set.
Below is what I came up with. This displays an empty TEXT field, but no data. I checked and the rs.getString(item) is returning some string data.
Can anybody tell me what change I need to make to the text below so it'll print out the rs.getString(item)>?
Thanks much.
-----------------------
out.println("<p><INPUT TYPE=TEXT, NAME= " + namVar + "VALUE= " + rs.getString(item)+"<p>");
(???)
 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

ITEM should be the name of the column in the db. (SELECT ITEM FROM TABLE), alternatively you can do this rs.getString( 1 ) which will return the 1st column your query returns.
 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this worked after I uncommented "ITEM".
Thank you very much!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic