• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Passing Values

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The short story is this. I build on the JSP page a drop down menu using a bit of java to make a database call (because it needs to be dynamic).
Now, the user should be able to select from the combo-box a value (no problem) but then I need to use that value to pass it to a piece of java code on the page to make another database call in order to grab some peremeters to build a table later on down the page.
I HAVE NO IDEA HOW TO DO ANYTHING IN HTML/JAVASCRIPT...please help me. I have poored over resource but I am simply lost in how to do this.

Thank you so much to anyone who can give me some solid guidance/examples.
[ April 07, 2005: Message edited by: Bear Bibeault ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on the select

<select onchange="document.formName.submit()"

it will post back the data to your server so you can do your next step. You most likely will have to reselect the option when your page rebuilds the select element.

Eric
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK...so I use <select onchange="document.formName.submit()" but how do I get the value back? I am not following, sorry.
I have something that looks like

except the values are placed in by some java code on the page doing an sql call.
Now when the user selects a value I want to drop that value into another sql call to finish the page...something like

Did that make since or am I just being a HTML moron? I would think this should be simple but...I never put HTML or JAVASCRIPT on my resume but appearently it is part of the job.

Thanks again for any help and thanks Eric, sorry about posting in the wrong place.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now when the user selects a value I want to drop that value into another sql call to finish the page.



You have a common misconception as to how JSP works. JSP is merely a template engine that allows you to dynamically build an HTML page to send to the browser. Once the page is sent to the browser, there is no way to get any code on the server to execute without submitting another request. You cannot just execute snippets of Java in response to a user's action.

Upon the user's selection, you must submit back to the server and re-render the page to make any changes.
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK...so how would you do it then? I noticed the original author of the code used Iframes to just hold sections of java code to execute and had the Iframes hidden...I don't know if I am coming across...I'm just frustrated because I can not figure out how to make something seamingly as simple as this work. If you could elaborate more or direct me to a good how to do it for dummies web-site I would appreaceate it.
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The easiest method is what I previously mentioned: repost back to the server and refresh the entire page with appropriate changes.

The iframe business is a rather advanced technique that I've used in the past. By posting to the hidden iframe, a round-trip to the server can be made without refreshing the parent page. The response to the iframe post would contain Javascript that would be used to affect the parent page with the results of the operation.
[ April 07, 2005: Message edited by: Bear Bibeault ]
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I am doing an onchange in my combo box and then I will forward to another page (identicle to the original) but how do I pass the selected value to the duplicate page...I mean what is teh call to pass it and then how do I get it back out?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pat,
I would strongly recommend taking some time away from this project to follow a few JSP/Servlet tutorials. There is a chapter in "Core Servlets And Java Server Pages" devoted to explaining how HTML forms work. Without understanding some of the fundamental concepts of web programming all the explanations you get from people in this forum will only confuse you further.
 
reply
    Bookmark Topic Watch Topic
  • New Topic