Solved

Multiple target in a single submit in a form

Posted on 2004-10-07
13
299 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
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

772 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