frames and $_POST. How to

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fjm
    Contributor
    • May 2007
    • 348

    frames and $_POST. How to

    Hi all,

    I have an interface that will be using 2 horizantal frames. The top frame is the header and uses a select tag with javascript. When the onchange event occurs it uses the form action to post to frame 2.

    How can I get the $_POST var into frame 2? Should I be using a session for this?

    Thanks,

    Frank
  • fjm
    Contributor
    • May 2007
    • 348

    #2
    I have a bit more to report on this. My form tag is inside the header.php and is written as:

    Code:
    <form method="post" action="../../index.php" target="main">
    "Main" is the area that should be populated with the results from the form tag. What is interesting is that if I change my frameset name to "_top" and I do a print_r of the post var, I can see the value echoed there. :) When I change it back to "main" I get nothing.

    Should I be using _top instead of the frame name?

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Are you sending the value selected in the top frame as it is or are you calculating something (perhaps using some database vales) to come up with what should be displayed in the bottom frame? Generally this should be possible using Javascript or AJAX(if you need to use database values).

      Comment

      • fjm
        Contributor
        • May 2007
        • 348

        #4
        Originally posted by r035198x
        Are you sending the value selected in the top frame as it is or are you calculating something (perhaps using some database vales) to come up with what should be displayed in the bottom frame? Generally this should be possible using Javascript or AJAX(if you need to use database values).
        Hi r035198x,

        Thanks for the help. The value from the top frame is being dynamically generated from a database and that "value" is what I need to be passed in the lower "main" frameset. I'm not calculating anything per se but only querying for the value to be passed.

        I must admit that it has been probably 10 years since I have done anything with frames and I have forgotten most of what I knew. I think it is possible to get the value from frame1 into frame2; I just think part of my problem is my lack of knowledge of frames.

        What I have done and it actually seems to be working is that I have changed the name in the form tag from index.php to body.php. Body.php is what will handle most of the db processing and then rendered to the lower frame.

        When I made that change, it worked perfect. I can see the post var being echo'd just fine. Is this the way that frames should work?

        Another thing that bothers me is since the body.php will be doing the processing, I will need to pass the value of the top frame into it. How am I going to handle that? Should I pass the value into the index.php where the frameset resides or pass it into the body.php file?

        BTW: I feel honored that the actual admin of the site (with over 10k posts) answered me. :)

        Thanks,

        Frank

        EDIT:
        I had forgotten to add that the "frame src" must be a file.
        Code:
        <frame src=\"body.php\" name=\"main\">\n";
        How would I instantiate an object in place of the file? I would like to use OO methodologies here.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by fjm
          Hi r035198x,

          Thanks for the help. The value from the top frame is being dynamically generated from a database and that "value" is what I need to be passed in the lower "main" frameset. I'm not calculating anything per se but only querying for the value to be passed.

          I must admit that it has been probably 10 years since I have done anything with frames and I have forgotten most of what I knew. I think it is possible to get the value from frame1 into frame2; I just think part of my problem is my lack of knowledge of frames.

          What I have done and it actually seems to be working is that I have changed the name in the form tag from index.php to body.php. Body.php is what will handle most of the db processing and then rendered to the lower frame.

          When I made that change, it worked perfect. I can see the post var being echo'd just fine. Is this the way that frames should work?

          Another thing that bothers me is since the body.php will be doing the processing, I will need to pass the value of the top frame into it. How am I going to handle that? Should I pass the value into the index.php where the frameset resides or pass it into the body.php file?
          ...
          I'm not a fan of frames myself. You'll probably need to handle the case when the user's browser is not supporting them.
          If the value to be displayed on the second frame is from database look-up then you probably want to use AJAX to refresh that value in the bottom frame. That means the whole page is not submitted. The form submit in that case will call a Javascript function rather than the PHP file. The PHP file will then be called by the AJAX call.



          Originally posted by fjm
          ...

          BTW: I feel honored that the actual admin of the site (with over 10k posts) answered me. :)

          Thanks,

          Frank
          10k posts can just as well be obtained by posting nonsense so I wouldn't read much into that.

          Comment

          • fjm
            Contributor
            • May 2007
            • 348

            #6
            Thanks r035198x. I will look into AJAX for this. Unfortunately, never got into javascript so I have got a bit of studying to do. :)


            Thanks,

            Frank

            Comment

            Working...