Solved

Multiple target in a single submit in a form

Posted on 2004-10-07
13
274 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
  • 6
  • 3
  • 2
  • +2
13 Comments
 
LVL 5

Expert Comment

by:webtrans
Comment Utility
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
Comment Utility
Can you give me a working script please? so I could test it if its working?

thanks
0
 
LVL 5

Expert Comment

by:webtrans
Comment Utility
please check below
it have a working example
http://www.cross-browser.com/talk/inter-frame_comm.html
0
 

Author Comment

by:cwiggler
Comment Utility
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
Comment Utility
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
Comment Utility
> (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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
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
Comment Utility
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
Comment Utility
webtrans, are you going to help further with the frames problem?
0
 

Author Comment

by:cwiggler
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
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 the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now