• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Drop down Value and Submit

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have two questions here

i have 2 jsp pages.

first question?
in one jsp page i have link to go to second jsp page to get a value.
how do i get the value from second jsp page to first jsp page ?

second question ?
in the second jsp page i have list box
once i select a value in the list box the submit button should be enabled after value selection

then when i click submit it should take me the value that i selected to the first jsp page.

i am using struts-html tags

any suggestions or ideas with some samples are highly appreciated

thanks alot
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before I can answer this, I would need to know how these two pages are being displayed. Did you use Struts Tiles to display them both in the same physical page? Did you use HTML Frames with both JSPs in the same frameset in separate frames? Did the first JSP open up a popup window to display the second?
 
Chinni Bujji
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the first jsp page opens the second page as POP up
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is more than one way to do this, but here's what I'd suggest.

When you open a window using the JavaScript window.open() function, the window you opened has a property named "opener" that refers to the parent window. Once you have that reference, you can refer to or modify any element in the parent window. For example, opener.document.myForm.myText refers to a text input named myText in form myForm in the parent window.

Here's how I'd do it:
  • create a JavaScript Function that gets the input value in the second JSP and sets the value of some input in the parent JSP. (I'd suggest either a hidden field or a read-only text input).
  • Once the values are set the function should close the current window
  • Use the onclick even of the button to call the function

  • If you do it this way, the second JSP doesn't submit at all, but just uses JavaScript to set the value in the first JSP. Then, when the user submits the first JSP, all the values will be sent to the server.
     
    Chinni Bujji
    Ranch Hand
    Posts: 60
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    hello merill

    can you give me some sample code
     
    Merrill Higginson
    Ranch Hand
    Posts: 4864
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The parent JSP:

    The popup window:

    [ March 26, 2007: Message edited by: Merrill Higginson ]
     
    Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic