Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting a form to a different frame 2

Status
Not open for further replies.

anuktac

Technical User
Aug 1, 2002
48
0
0
IN
Hi,
I have a page, which consists of a top frame, and two side-by-side frames at the bottom:

<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS=&quot;30%,70%&quot; BORDER=0>
<FRAME SRC=&quot;/BusinessReview/html/br_top.html&quot; NAME=&quot;DisplaySite_frm&quot; noresize scrolling=&quot;no&quot;>

<FRAMESET COLS=&quot;20%,80%&quot; BORDER=0>
<FRAME SRC=&quot;/BusinessReview/servlet/MultiSelect&quot; NAME=&quot;MultiSelect_frm&quot; noresize scrolling=&quot;no&quot;>
<FRAME SRC=&quot;/BusinessReview/html/blank.htm&quot; NAME=&quot;MainFrame_frm&quot; noresize scrolling=&quot;auto&quot;>
</FRAMESET>

</FRAMESET>
</HTML>


Now, in my top frame (DisplaySite_frm), I have a form (frm_Getsite), where I enter a Code(called Sac_code), and when i submit the form, i want the output to be displayed in the frame MainFrame_frm.

The code for br_top.html is as below:

<html>
<head>
script language = javascript>
function submitpage()
{
var vsac=document.frm_GetSite.sac_code.value;
var servletpath=&quot;/BusinessReview/servlet/br_srv_DisplaySite?sac_code=&quot;+vsac;
parent.frames[1].location.href=&quot;/BusinessReview/html/crisp.html&quot;;
parent.frames[2].location.href=servletpath;

document.frm_GetSite.submit();
}
</script>
</head>
<FORM ACTION=&quot;&quot; TARGET=&quot;MainFrame_frm&quot; name=&quot;frm_GetSite&quot;>
<input type=text NAME=&quot;sac_code&quot; size=10>
<input type=button value=&quot;Get Sites&quot; onclick=&quot;javascript:submitpage()&quot;>
</form>
</html>


In the bottom left frame, the html page gets displayed fine, when I submit the form, but the servlet(br_srv_DisplaySite) does not execute.

Why does the servlet not get executed?

-Anukta [sadeyes]
 
>> Why does the servlet not get executed?

The form has no action associated with it. Ergo there is nothing for it to submit to. If you want the servlet to process the contents of the form, you need to specify that in the [tt]action[/tt] attribute that you currently have set to &quot;&quot;.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]
 
I had no action associated with the form because initially I wanted two servlets to run when I submitted the form.

something like this:


function submitpage()
{
var vsac=document.frm_GetSite.sac_code.value;
var servletpath1=&quot;/BusinessReview/servlet/br_srv_DisplaySite?sac_code=&quot;+vsac;
servletpath2=&quot;=&quot;/BusinessReview/servlet/br_srv_Multiselect&quot;
parent.frames[1].location.href=servletpath2;
parent.frames[2].location.href=servletpath;

document.frm_GetSite.submit();
}


This I could not do, if I had only one action associated with the form.

How can i run two servlets at a time so that data is posted in two different frames?

-Anukta
 
I had no action associated with the form because initially I wanted two servlets to run when I submitted the form.

something like this:


function submitpage()
{
var vsac=document.frm_GetSite.sac_code.value;
var servletpath1=&quot;/BusinessReview/servlet/br_srv_DisplaySite?sac_code=&quot;+vsac;
var servletpath2=&quot;=&quot;/BusinessReview/servlet/br_srv_Multiselect&quot;
parent.frames[1].location.href=servletpath2;
parent.frames[2].location.href=servletpath;

document.frm_GetSite.submit();
}


This I could not do, if I had only one action associated with the form.

How can i run two servlets at a time so that data is posted in two different frames?

-Anukta
 
You'd need two forms. One visible that your users fill in, another hidden somewhere. Each would have an action attribute that specified which servlet to post the data to.

On submition of the visible form, you need to copy the information from the it to the invisible one then trigger the invisible form's [tt]submit()[/tt] method.

A form will not submit information anywhere unless it has an action attribute.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]
 
Try this,
On your top frame write a javascript which will set the target of the 2 servlets to the corresponding frames and submit it.

function submitpage()
{
var vsac=document.frm_GetSite.sac_code.value;
var servletpath1=&quot;/BusinessReview/servlet/br_srv_DisplaySite?sac_code=&quot;+vsac;
var servletpath2=&quot;/BusinessReview/servlet/br_srv_Multiselect&quot;;

document.frm_GetSite.action=servletpath1;
document.frm_GetSite.target='MultiSelect_frm';
document.frm_GetSite.submit();

document.frm_GetSite.action=servletpath2;
document.frm_GetSite.target='MainFrame_frm';
document.frm_GetSite.submit();
}
 
Thanks everyone.
It worked when I set one of the servlets in the ACTION attribute, and the other servlet in the ONSUBMIT attribute.And also setting the TARGET attribute.

You are right when you said that it did not work when the form did not have any action associated with it. It needed at least one action.

thanks a lot
Anukta
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top