Solved

Multiple target in a single submit in a form

Posted on 2004-10-07
13
325 Views
Last Modified: 2012-06-21
Hi all,

I have a problem dealing with frames and forms. I created 4 frames, top, leftside, main and bottom frames on my index page. in the leftside frame, i created a search button. if I do a search let say username, I want to display the information of that user in the main frame and i can do that. my problem is, I want also to display some information of that user in the bottom frame. how can i do that?

I created a form with something like this and this works fine:
<FORM METHOD=POST ACTION="clientsearch.html" target="main">

I would like to make something like this so I could update the bottom frame also and I know its not possible for this code:
 <FORM METHOD=POST ACTION="clientsearch.php" target="stats" target="bottom">

What is the best solution for this? I really badly need to solve it.

thanks alot.
0
Comment
Question by:cwiggler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +2
13 Comments
 
LVL 5

Expert Comment

by:webtrans
ID: 12247591
well best solution is using javascript to update such an info but after you get it in the main frame
0
 

Author Comment

by:cwiggler
ID: 12247616
Can you give me a working script please? so I could test it if its working?

thanks
0
 
LVL 5

Expert Comment

by:webtrans
ID: 12247652
please check below
it have a working example
http://www.cross-browser.com/talk/inter-frame_comm.html
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:cwiggler
ID: 12247727
Hi Webtrans,

thanks for the link, i read it on and try the sample but i dunno if thats what i want to achieve since im dealing with form to submit and not by link. maybe if you have the solution and can share with me it would be very appreciated.

thanks
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12248024
Webtrans is on the right track so I will let him work it out ...
basically you store the extra information in hidden fields in the main frame and then when the frame loads move the relevant stuff to the bottom frame.

However, I just wanted to caution you not to name your top frame "top" since that is a reserved word in javascript and may cause you problems.  Call it "topframe" or something like that instead.

(FYI - a similar problem will exist if you name your submit button "submit".  better to use "Submit" or "btnSubmit" or anything but "submit" :)
0
 
LVL 10

Expert Comment

by:eeBlueShadow
ID: 12248205
> (FYI - a similar problem will exist if you name your submit button "submit".  better to use "Submit" or "btnSubmit" or anything but "submit" :)

Aside: Can you link me to some official documentation on this, I've never had any problems with it but this isn't the first time I've heard someone say it
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12249051
Here is my official documentation :)


<HTML>
<BODY>
<FORM name="myform" action="javascript:alert('Form Submitted!');">
 This form will not submit unless you change the name of the button from "submit" to something else:<BR>
 <INPUT type="button" name="submit" value="Click to Submit" onclick="this.form.submit();" />
</FORM>
</BODY>
</HTML>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12251545
note:  naming the button "submit" is only a problem if you try to programmatically submit the form using the submit() method.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12251551
webtrans, are you going to help further with the frames problem?
0
 

Author Comment

by:cwiggler
ID: 12255573
knightEknight,

can you give me a solution please on the frames problem, i still can get it. im not good in javascript language, maybe you can help me.

thanks
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 125 total points
ID: 12258066
ok ... I am assuming that you renamed your top frame to "topframe" instead of "top", and that your form tag looks like this, so that the results show up in the "main" frame in clientsearch.php:

   <FORM  name="leftForm"  method="POST"  action="clientsearch.php"  target="main" >

You want to display some of the fields in the main frame and some in the bottom frame.  But since you can only submit to one target at a time, all of the data will go to the main frame first.  Some of it you should display, and the rest you put into hidden fields.  For example, if you want to display the user name in the main frame, but the user email address in the bottom frame, then first do this in the bottom frame:

   <FORM name="bottomForm">
     <INPUT type="text" name="email" value="" />
   </FORM>

... and do this in the main form, which gets its values posted from the original form in the left frame

   <BODY onload="top.frames['bottom'].document.bottomForm.email.value = document.mainForm.email.value;">
   <FORM name="mainForm">
     <INPUT type="text" name="username" value="<?php echo($username)?>" />
     <INPUT type="text" name="email" value="<?php echo($email)?>" />
   </FORM>
   </BODY>

(keep in mind that I don't know PHP, so I'm guessing at the "echo" syntax above.)



0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12258115
another (and perhaps better) way to do it would be to put all of the data to be displayed in the bottom frame into a seperate hidden form on the main frame, and submit that form to the bottom frame when the page loads:


clientsearch.php in the main frame:

<BODY onload="document.tBottomForm.submit();">

  Displayed Username (submitted from the left frame): <?php echo(&username)?>

  <FORM name="tBottomForm" target="bottom" action="bottomSearch.php" method="post">
    <INPUT type="hidden" name="email" value="<?php echo($email)?>" />
  </FORM>

</BODY>
0
 
LVL 2

Expert Comment

by:jklNYC
ID: 12289108
what about using multiple forms that all submit on the click of 1 button?
============
in the frame with your search form:
<body>
<form name="frm1" method="post" action="clientsearch.html" target="main">
<input type="text" name="userName" > <input type="button" value="search" onClick="submitForms();">
</form>

<form name="frm2" method="post" action="clientsearch.php" target="stat">
<input type="hidden" name="userName" value="">
</form>

<form name="frm3" method="post" action="clientsearch.php" target="bottom">
<input type="hidden" name="userName" value="">
</form>

<script>
function submitForms() {
   document.frm3.userName = document.frm1.userName.value;
   document.frm3.submit();

   document.frm2.userName = document.frm1.userName.value;
   document.frm2.submit();

   document.frm1.submit();
}
</script>
</body>

You can see a sample of what i mean here:  http://www.jklbruin.com/test/default.html
============
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question