Meaningless Drivel is fun!*
The moose likes JSP and the fly likes populating textarea from dropdown box selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "populating textarea from dropdown box selection" Watch "populating textarea from dropdown box selection" New topic
Author

populating textarea from dropdown box selection

dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
Hi all

I have a drop-down list which is populated dynamically from a database table

I'm trying to populate a textarea when a selection is made from a drop-down box on the same page

Is anyone able to show mw how to do this?

My code for the drop-down box


What i then want to do is take the 'id' value (from the selection made from the drop-down box) and pass this to another sql query e.g. select * from table1 where id = <%=id%>, so i can get the contents and populate the textarea which is on the same page as the drop-down box

any help much appreciated
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

You have a grave misconception regarding how JSP works. All that code that you have in the JSP is executing on the server long before the page is sent to the browser. So it is impossible for it to react to on-page events such as dropdown selections.

Perhaps this article will shed some light on what really goes on during the life-cycle of a JSP.

After reading it, you should understand why the approach you propose can never work, and that you need to use Javascript, perhaps with the help of some Ajax, in order to accomplish what you are trying to do.
[ April 02, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
Got this working now

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: populating textarea from dropdown box selection
 
Similar Threads
onChange Event to call a frame.
Stuck with AJAX implementation on form reload
dynamic query to display dynamic results??
How to get last selected value in list box?
accessing database using javascript