SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: FORM data to multiple locations
-
Mar 14, 2001, 00:20 #1
- Join Date
- Mar 2001
- Location
- Melbourne, Australia
- Posts
- 1,039
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is it possible to submit a form, and for the form data to be passed to more than 1 location at the same time?
I'm working on a shopping cart application using frames. When the user has input some data into a form and clicks SUBMIT, I need all the form data to be available to the code in two different frames at the same time.
I can write the form data to the MySQL database and read it back, but seeing as both of the frames need to act on the form data simultaneously, it's unlikely that script 'A' will finish (or even start) writing the data before script 'B' wants to read it.
I'm using PHP & MySQL by the way, with Javascript where appropriate. My hunch would be that the solution involves some javascript in the FORM element, but my Javascript talents aren't that hot.
Any suggestions anyone?
-
Mar 14, 2001, 11:25 #2
- Join Date
- May 2000
- Location
- Salt Lake City, UT
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How are you using the form data in both frames?
When the frame with the form is submitted, that form information is only available in that frame to PHP. What you could do then, is write a javascript in PHP that passes the values to the other frame.
I really don't know what you need the values to be passed to in the other frame so I don't know how to really answer you question.
Also, try posting in the PHP/MySQL forum. There are bigger fish than me there that can answer your php questions better than I can. If it's a javaScript solution, I can help, but you'd have better luck with this question in the other forum I think.Joe Eliason
Just a dog learnin' PHP from cat.
-
Mar 14, 2001, 19:20 #3
- Join Date
- Mar 2001
- Location
- Melbourne, Australia
- Posts
- 1,039
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi HotDog, and thanks for your interest.
I'm working with multiple frames (I'm not a big fan of frames myself, but the client likes them...), but for the sake of this example I'm only dealing with 2 frames. Frame 'A' is a form. Frame 'B' is the list of items in the customers shopping cart. When the user submits the form in Frame 'A', I need all the user supplied data contained in that form to be passed back to Frame 'A' AND to Frame 'B', since the scripts in both frames need to act upon that data.
I don't feel that it's necessary to understand the application - just that all of the form data needs to be passed to two different scripts/pages/locations simultaneously.
eg. <FORM action="page1.htm" action="page2.htm" ... >
Of course the above will not work, but it helps to explain what I'm trying to achieve. I'm convinced that javascript will be the solution, because I know it can do 'fancy' things on the client-side.
-
Mar 14, 2001, 20:55 #4
- Join Date
- May 2000
- Location
- Salt Lake City, UT
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this:
Setup your frame page:
Code:<html> <frameset cols="18%,82%"> <frame name="frameA" src="frameA.php"> <frame name="frameB" src="frameB.php"> </frameset> </html>
Code:<html> <body> <form method="post" action="<?=$PHP_SELF?>" name="formA"> <input type="hidden" name="value1" > </form> <?php echo $value1; ?> </body> </html>
Next, tell the other page to submit it's form to itself. This will give the php variables values on the other page.
In your main form, setup a hidden field so when the form is submitted, the php code knows it needs to kick-in at the beginning of the document and pass the values to the other page.
Again, submit the page to itself:
Code:<html> <head> <?php if ($edit) : ?> <script language="javaScript"> parent.frameA.document.formA.value1.value="<?=$value1?>"; parent.frameA.document.formA.submit(); </script> <?php endif; ?> </head> <body> <form method="get" action="<?=$PHP_SELF?>" name="formA"> <input type="hidden" name="edit" value="1"> <input name="value1" type="text"> <input type="submit" name="SUBMIT"> <br><br><br> <?php print $value1; ?> </body> </html>
Try it out and let me know how it works. You will, of course, need to modify it to fit your needs. But if you take this example, it should solve your problem.
Ruff!!!Joe Eliason
Just a dog learnin' PHP from cat.
Bookmarks