passing vars - popup window problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    #1

    passing vars - popup window problem

    Hi,

    I currently have a problem passing a variable value from one page to
    another. Once a form submit button is pressed java pops up a window and
    displays some information. The problem being is variables value needs to
    be passed from the main page to this popup window ... but it isn't. why?


    the submit button one the PHP page is

    $s_download_act ion = "index.$phpEx?p age=downloads";

    $download_url = "download.$phpE x";

    $hidden_downloa d_vars = '<input type="hidden" name="download_ id"
    value="' . $d_id . '" />';
    $u_download = "<input type=\"submit\" name=\"get_down load\" value=\"" .
    $lang['Download'] . "\" class=\"mainopt ion\" onClick=\"windo w.open('" .
    $download_url . "', '_spdownload', 'HEIGHT=250,res izable=yes,WIDT H=
    400');return false;\" />";


    echo '<form action="' . $s_download_act ion . '" method="post">' ;
    echo $hidden_downloa d_vars . '' . $u_download;
    echo '</form>';
  • Jerry Stuckle

    #2
    Re: passing vars - popup window problem

    Steve wrote:[color=blue]
    > Hi,
    >
    > I currently have a problem passing a variable value from one page to
    > another. Once a form submit button is pressed java pops up a window and
    > displays some information. The problem being is variables value needs to
    > be passed from the main page to this popup window ... but it isn't. why?
    >
    >
    > the submit button one the PHP page is
    >
    > $s_download_act ion = "index.$phpEx?p age=downloads";
    >
    > $download_url = "download.$phpE x";
    >
    > $hidden_downloa d_vars = '<input type="hidden" name="download_ id"
    > value="' . $d_id . '" />';
    > $u_download = "<input type=\"submit\" name=\"get_down load\" value=\"" .
    > $lang['Download'] . "\" class=\"mainopt ion\" onClick=\"windo w.open('" .
    > $download_url . "', '_spdownload', 'HEIGHT=250,res izable=yes,WIDT H=
    > 400');return false;\" />";
    >
    >
    > echo '<form action="' . $s_download_act ion . '" method="post">' ;
    > echo $hidden_downloa d_vars . '' . $u_download;
    > echo '</form>';[/color]

    This looks more like javascript, not java.

    And I don't see any problem with your PHP code. But it looks like there
    are problems with your html and javascript.

    First of all - the submit button isn't in the form. Why not? Or is
    there more you haven't shown us?

    Next, I don't see where you're passing the value to the popup window in
    your javascript.

    Try a javascript newsgroup.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Tyxod

      #3
      Re: passing vars - popup window problem

      "Try a javascript newsgroup." - nope this is more of an html question.
      Maybe try an html newsgroup, as this is a common html mistake...

      Anyway, the problem is that you are passing a get variable here
      (instead of a post var):

      $s_download_act ion = "index.$phpEx?p age=downloads";

      which is the wrong way to sumbit a get variable through an html form
      anyway. Especially when you declare:

      method="post"

      The possible solution is to have a hidden field like:

      <input type="hidden" name="something " value="$s_downl oad_action">

      and then catch that in the popup as:

      $s_download_act ion_is=$_POST['something'];

      of course, if you wish to use

      method="get"

      then the above would be

      $s_download_act ion_is=$_GET['something'];

      Comment

      • d

        #4
        Re: passing vars - popup window problem

        "Steve" <stuck@need_hel p.co.uk> wrote in message
        news:Xns97877EA 21852Csjoinesnt lworldcom@195.9 2.193.157...[color=blue]
        > Hi,
        >
        > I currently have a problem passing a variable value from one page to
        > another. Once a form submit button is pressed java pops up a window and
        > displays some information. The problem being is variables value needs to
        > be passed from the main page to this popup window ... but it isn't. why?
        >
        >
        > the submit button one the PHP page is
        >
        > $s_download_act ion = "index.$phpEx?p age=downloads";
        >
        > $download_url = "download.$phpE x";
        >
        > $hidden_downloa d_vars = '<input type="hidden" name="download_ id"
        > value="' . $d_id . '" />';
        > $u_download = "<input type=\"submit\" name=\"get_down load\" value=\"" .
        > $lang['Download'] . "\" class=\"mainopt ion\" onClick=\"windo w.open('" .
        > $download_url . "', '_spdownload', 'HEIGHT=250,res izable=yes,WIDT H=
        > 400');return false;\" />";
        >
        >
        > echo '<form action="' . $s_download_act ion . '" method="post">' ;
        > echo $hidden_downloa d_vars . '' . $u_download;
        > echo '</form>';[/color]

        Your form is not actually submitting anything. The submit button is
        returning false, which will cancel the form being submitted anywhere. You
        could replace the submit with a button, have that create a new window, have
        the new window (once loaded) call the opening document, and submit the form
        to itself. You can specify a name for the window in the javascript that
        creates it, and you can specify a "target" in your <form>. It's messy, but
        will have you submitting to a pop-up box.

        Posting to a pop-up box seems somewhat dirty. :-P


        Comment

        • Steve

          #5
          Re: passing vars - popup window problem

          "d" <d@example.co m> wrote in
          news:MQVRf.3632 8$wl.22600@text .news.blueyonde r.co.uk:
          [color=blue]
          > "Steve" <stuck@need_hel p.co.uk> wrote in message
          > news:Xns97877EA 21852Csjoinesnt lworldcom@195.9 2.193.157...[color=green]
          >> Hi,
          >>
          >> I currently have a problem passing a variable value from one page to
          >> another. Once a form submit button is pressed java pops up a window
          >> and displays some information. The problem being is variables value
          >> needs to be passed from the main page to this popup window ... but it
          >> isn't. why?
          >>
          >>
          >> the submit button one the PHP page is
          >>
          >> $s_download_act ion = "index.$phpEx?p age=downloads";
          >>
          >> $download_url = "download.$phpE x";
          >>
          >> $hidden_downloa d_vars = '<input type="hidden" name="download_ id"
          >> value="' . $d_id . '" />';
          >> $u_download = "<input type=\"submit\" name=\"get_down load\" value=\""
          >> . $lang['Download'] . "\" class=\"mainopt ion\"
          >> onClick=\"windo w.open('" . $download_url . "', '_spdownload',
          >> 'HEIGHT=250,res izable=yes,WIDT H= 400');return false;\" />";
          >>
          >>
          >> echo '<form action="' . $s_download_act ion . '" method="post">' ;
          >> echo $hidden_downloa d_vars . '' . $u_download;
          >> echo '</form>';[/color]
          >
          > Your form is not actually submitting anything. The submit button is
          > returning false, which will cancel the form being submitted anywhere.
          > You could replace the submit with a button, have that create a new
          > window, have the new window (once loaded) call the opening document,
          > and submit the form to itself. You can specify a name for the window
          > in the javascript that creates it, and you can specify a "target" in
          > your <form>. It's messy, but will have you submitting to a pop-up
          > box.
          >
          > Posting to a pop-up box seems somewhat dirty. :-P
          >
          >
          >[/color]

          I see your point about being dirty! but its only a confirmation window
          once the download button is pressed. basically its just saying "The
          requested file 'blahblahblah.z ip' will download in the next 3 seconds.

          might look at onther way instead ... but thanks anyway.

          Comment

          • Steve

            #6
            Re: passing vars - popup window problem

            "Tyxod" <yrizos@gmail.c om> wrote in news:1142427614 .295685.117830
            @i39g2000cwa.go oglegroups.com:
            [color=blue]
            > "Try a javascript newsgroup." - nope this is more of an html question.
            > Maybe try an html newsgroup, as this is a common html mistake...
            >
            > Anyway, the problem is that you are passing a get variable here
            > (instead of a post var):
            >
            > $s_download_act ion = "index.$phpEx?p age=downloads";
            >
            > which is the wrong way to sumbit a get variable through an html form
            > anyway. Especially when you declare:
            >
            > method="post"
            >
            > The possible solution is to have a hidden field like:
            >
            > <input type="hidden" name="something " value="$s_downl oad_action">
            >
            > and then catch that in the popup as:
            >
            > $s_download_act ion_is=$_POST['something'];
            >
            > of course, if you wish to use
            >
            > method="get"
            >
            > then the above would be
            >
            > $s_download_act ion_is=$_GET['something'];
            >[/color]

            the variable I am trying to obtain is a hidden var

            $hidden_downloa d_vars = '<input type="hidden" name="download_ id"
            value="' . $d_id . '" />';


            which is in the form like this

            echo '<form action="' . $s_download_act ion . '" method="post">' ;
            echo $hidden_downloa d_vars . '' . $u_download;
            echo '</form>';


            the get var your on about in the form element is not the var i am trying
            to obtain in the popup window. I need the download_id var as above.

            will try it as GET anway and see what happens.

            thanks.

            Comment

            Working...