Link to home
Start Free TrialLog in
Avatar of cwiggler
cwiggler

asked on

Multiple target in a single submit in a form

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.
Avatar of webtrans
webtrans

well best solution is using javascript to update such an info but after you get it in the main frame
Avatar of cwiggler

ASKER

Can you give me a working script please? so I could test it if its working?

thanks
please check below
it have a working example
http://www.cross-browser.com/talk/inter-frame_comm.html
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
Avatar of knightEknight
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" :)
> (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
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>
note:  naming the button "submit" is only a problem if you try to programmatically submit the form using the submit() method.
webtrans, are you going to help further with the frames problem?
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
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>
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
============