This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Form submission and iFrame 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 » Engineering » HTML, CSS and JavaScript
Bookmark "Form submission and iFrame" Watch "Form submission and iFrame" New topic
Author

Form submission and iFrame

Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
I have a JSP with a FORM which includes an iFrame.
This JSP has a button which submits the FORM and all of its elements to the servlet.
Inside the iFrame, I display a list of tours. Each tour has got a radio button with it. The user must be able to check the radio button of one tour if he/she wants to see the details of this tour. With the submit button the user must be able to ask the servlet to show the details for the tour with the checked radio button.

But remember : the submit button is in the form of the JSP, the radio button is in the iFrame.
When I submit the form, I can read the value of the different elements of the <FORM>, but I can�t read the value of the checked radio button. This radio button is in the iFrame (which I have put inside the <FORM> .

My question is : is it possible to read the values of the checked radio button of the iFrame ? Does the submitted FORM communicate the values of every element to the servlet including the values of the iFrame ?
Or is an iFrame considered being completely apart from the FORM ?
[ May 22, 2004: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60738
    
  65

No, the iframe is an entirely separate page, so no form elements within it will be automaticaly submitted with the form.

One thing you could do is to, in an onsubmit handler, use Javascript to read the iframe values and set them onto the form as hidden parameters.

But first I would question the use of the iframe to begin with and replace it with a scrollable div so that there is no separate page to contend with.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
thanks for the advice, Bear. I didn't even know of the existence of the scrollable div. But since the iFrame gives me a complete other page, it seems much better to use the scrollable div.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60738
    
  65

Check out the overflow CSS rule.

Because this is much more about HTML than JSP, I'm moving this off to the HTML/Javascript forum.

I also edited the title a bit to be a bit more accurate.
[ May 22, 2004: Message edited by: Bear Bibeault ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
One other thing that you could do is add an onclick handler to the radio button that updates a hiddem form element on the main page

basic idea


Eric
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Form submission and iFrame
 
Similar Threads
doubt in getParameter()
Ajax Calls not refereshed.
Arraylist in JSP with Html radio
how to pass field value in an IFrame to its parent
Pass radio button to servlet