• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How To Dynamically Display the Content of a Page that is Selected from a Menu?

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web page that displays a drop-down menu, a textarea, and a submit button.

The drop-down menu is for users to select "one" from a list of pages. Once the page is selected, the content of that page is supposed to show up in the textarea right below the drop-down menu and the user can start editing that page. Upon finishing editing, the user clicks on the Submit button.

To the best of my knowledge, it involves an action to search in the database tables to search for the page selected, and then, the content of the page can be displayed in the next step.

I have not used the JavaScript before. People suggest that I can use an onChange JavaScript listener on the drop-down that submits to an Action -- that Action retrieves the data for the textarea and forwards back to the original form. Could anybody guide me to do it?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript is not going to be able to get the information from the database, you are going to have to submit the page back to the server in order to place the information into the text box.

Eric
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that it can be done. Would you please just take a look at
https://www.swern.gov/forms/enrollmeform.php

and scroll down a little below half way. There is a drop-down menu for the 'Select Program Group'. And there is a textarea right below that drop-down menu.

Simply select a group from the drop-down menu, you will see a description of that program group appears in the textarea. I wonder how it is done.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move your mouse cursor to Edit. Click. Select View Source. Click. Read.

You will see that all those selections are preloaded into the huge HTML file loaded into the browser.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic