• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSP and radio buttons passing values

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok read through many post here about radio buttons and jsp. Some come close to answering question, but not close enough.

I have a webpage that has 2 frames, and in those to frames are seperate jsp. The top is the header, which has nice picture and a row of four radio buttons.

<td>
<input type="radio" value="today" name="timeFrame" checked/><b>Today</b>
<input type="radio" value="week" name="timeFrame"/><b>7 Days<b>
<input type="radio" value="month" name="timeFrame"/><b>30 Days<b>
<input type="radio" value="all" name="timeFrame"/><b>All Days<b>
</td>

The bottom frame has jsp that displayes info. According to time span. Example last 7 day, last 30 days , today, and all days.

Now my problem is I need to make it so the radio buttons on the first jsp page at top frame are connected somehow to the 2nd jsp at bottom so that when a user clicks on one of the radio buttons at top the bottom jsp responds by showing the approprate page.

I do not know how to pass the value of the radio button that is chosen to the 2nd jsp page?

The 2nd page has the <@ code in it to diplay the appropriate page. I just dont get how to tell the 2nd jsp page what radio button on the 1st jsp page is choosen.

Any help much appreciated.

Thank you
 
Sheriff
Posts: 67752
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
You will need to load the bottom page using Javascript. Movig this along to the HTML/Javascript forum.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basic idea:



Eric
 
Susan Crystal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi thanks for reply...

I am not certain i understand what you have shown me. I dont see how the value(for example in my code "today") gets passed to a java method in a jsp.

I am not certain why my post was moved ...my question was about jsp, java not javascript. I do know the difference.

I need to pass the value of variable from the radio button depending on which is clicked. It needs to be passed to a method inside the JSP number 2 which is deplayed inside frame 2, hince java not javascript.

If using javascript is way to go then fine no problem with using it. It is just that the java method i want to pass variable to does some date stuff and database looking up. Kinda complicated and did not want to have to mess with it, just hand it the variable and run

any help appreciated

thanks
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to get the data to that frame somehow. This is just pasing data from the client to the server. Hence why it was moved to this forum.

You can use the method I shown with a query string. That will allow you to access it wih your server side code.

If that does not work, then you need to submit the form in the top frame. In order to do that, you can set the target attribute with the frame name.

Those are the two ways to do it.

Eric
 
Susan Crystal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Humm...

I came across the target=mainFrame thing for instance but I dont see what code actullay passes the variable to the method inside 2nd jsp?

The method name i am calling wich is java code not javascript is called display().

simple by the user selecting the radio button. Does that pass the value "today" to the java method display()? hince java not javascript

I tried this but the jsp2 is oblivious to that it has been passed anything.

thanks
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frames act like seperate windows, your Java Code can not talk between them. The only way that you are going to get data from the client side (radio buttons) to the server side (your function display()) is by submitting a form or a querystring.

On your Java code you need to look at the querystring or the form submission parameters that are passed to the server. With that data you should be able to get the value "today" which you are after.

The JavaScript code is just giving you the ability to submit the form or create a querystring so the user does not have to click a button.

With JavaScript, you can submit the form with document.formName.submit();

you can add it to the onclick event like onclick="document.formName.submit();"

So now when the user selects a radio button the form in the top frame is submitted and you place the target to your other frame. That frame can then grab the value from the form submission.

Eric
 
Yup, yup, yup. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic