Javascript var to php script

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

    Javascript var to php script

    Sorry to have to ask again, but my ISP's server has some issues I think,
    almost anything on this ng dating before 12th of this month is no longer
    available all of a sudden. And I don't think I got an answer to my original
    post. Not sure if that was because my question was very lame or ill-worded,
    or I am asking for something ridiculous perhaps ?

    I am still looking for the correct way or a correct way to achieve the
    following:
    I have some JavaScript on a page that produces a couple of variables I'd
    like to store in a db on my web server without having to ask the user to
    input them manually in a form again. (would be rather silly)
    How should I do this ? Am I missing something very obvious ?

    (in the Jscript group I got no answer either...) And I am not yet aware of
    how to crosspost.
    Sorry for the inconvenience, TIA for your help.
    Pjotr


  • Guest's Avatar

    #2
    Re: Javascript var to php script

    > I am still looking for the correct way or a correct way to achieve the[color=blue]
    > following:
    > I have some JavaScript on a page that produces a couple of variables I'd
    > like to store in a db on my web server without having to ask the user to
    > input them manually in a form again. (would be rather silly)
    > How should I do this ? Am I missing something very obvious ?[/color]

    There are many ways to achieve this. The simply method is to simply pass
    your javascript variable values to a hidden field in a form, then submit the
    form.

    If you do not want the user to have to click a submit button, you could fire
    the submit form even with the following javascript:

    document.all.my formsname.submi t();

    _______________ _______________ ______
    Wil Moore III, MCP | Integrations Specialist


    Comment

    • Justin Koivisto

      #3
      Re: Javascript var to php script

      Pjotr Wedersteers wrote:
      [color=blue]
      > Sorry to have to ask again, but my ISP's server has some issues I think,
      > almost anything on this ng dating before 12th of this month is no longer
      > available all of a sudden. And I don't think I got an answer to my original
      > post. Not sure if that was because my question was very lame or ill-worded,
      > or I am asking for something ridiculous perhaps ?
      >
      > I am still looking for the correct way or a correct way to achieve the
      > following:
      > I have some JavaScript on a page that produces a couple of variables I'd
      > like to store in a db on my web server without having to ask the user to
      > input them manually in a form again. (would be rather silly)
      > How should I do this ? Am I missing something very obvious ?[/color]

      You could send the data over to another php script in a separate window
      via a GET request...

      1. generate the values
      2. use window.open
      3. process you php script, then send a window.close via javascript so
      the window disappears.

      However, how well this will work because of popup blockers. Of course,
      you could just re-request the page with the GET vars in it when the
      value has been calculated...

      --
      Justin Koivisto - spam@koivi.com
      PHP POSTERS: Please use comp.lang.php for PHP related questions,
      alt.php* groups are not recommended.

      Comment

      • drwxr-xr-x

        #4
        Re: Javascript var to php script

        On Fri, 16 Jul 2004 03:39:53 +0200, Pjotr Wedersteers hath writ:[color=blue]
        > Sorry to have to ask again, but my ISP's server has some issues I think,
        > almost anything on this ng dating before 12th of this month is no longer
        > available all of a sudden. And I don't think I got an answer to my original
        > post. Not sure if that was because my question was very lame or ill-worded,
        > or I am asking for something ridiculous perhaps ?[/color]

        And, you did not think to check
        via:



        ?

        Comment

        • Brian Scott O'keefe

          #5
          Re: Javascript var to php script

          Justin Koivisto <spam@koivi.com > wrote in message news:<yEQJc.198 $jz4.9668@news7 .onvoy.net>...[color=blue]
          > Pjotr Wedersteers wrote:
          >[color=green]
          > > Sorry to have to ask again, but my ISP's server has some issues I think,
          > > almost anything on this ng dating before 12th of this month is no longer
          > > available all of a sudden. And I don't think I got an answer to my original
          > > post. Not sure if that was because my question was very lame or ill-worded,
          > > or I am asking for something ridiculous perhaps ?
          > >
          > > I am still looking for the correct way or a correct way to achieve the
          > > following:
          > > I have some JavaScript on a page that produces a couple of variables I'd
          > > like to store in a db on my web server without having to ask the user to
          > > input them manually in a form again. (would be rather silly)
          > > How should I do this ? Am I missing something very obvious ?[/color]
          >
          > You could send the data over to another php script in a separate window
          > via a GET request...
          >
          > 1. generate the values
          > 2. use window.open
          > 3. process you php script, then send a window.close via javascript so
          > the window disappears.
          >
          > However, how well this will work because of popup blockers. Of course,
          > you could just re-request the page with the GET vars in it when the
          > value has been calculated...[/color]

          Or...
          Instead of a whole new window...
          Have js create a frame inside of the current page.
          Set the HREF to: http://your_url.com/variableStore.p hp?variable_1=' whatever'&varia ble_2='anotherW hatever'

          Then:
          variableStore.p hp ::
          <?php
          // $variable_1 and $variable_2 are now available for manipulation
          // Put whatever database connectivity you need here.
          // REMEBER: Do NOT echo, print, or anything else that outputs to the
          screen
          // Or else your little frame might show it.
          ?>

          The <frame> that holds the variableStore.p hp file could have an OnLoad
          event that triggers... waits 30 seconds... the REMOVES the <frame> tag
          from the page. Harder for the user to find out what you did that
          way...

          Good luck..

          Comment

          • Chung Leong

            #6
            Re: Javascript var to php script


            "Brian Scott O'keefe" <randomblink@ya hoo.com> wrote in message
            news:5ec923cc.0 407161145.11466 7f@posting.goog le.com...[color=blue]
            > Justin Koivisto <spam@koivi.com > wrote in message[/color]
            news:<yEQJc.198 $jz4.9668@news7 .onvoy.net>...[color=blue][color=green]
            > > Pjotr Wedersteers wrote:
            > >[color=darkred]
            > > > Sorry to have to ask again, but my ISP's server has some issues I[/color][/color][/color]
            think,[color=blue][color=green][color=darkred]
            > > > almost anything on this ng dating before 12th of this month is no[/color][/color][/color]
            longer[color=blue][color=green][color=darkred]
            > > > available all of a sudden. And I don't think I got an answer to my[/color][/color][/color]
            original[color=blue][color=green][color=darkred]
            > > > post. Not sure if that was because my question was very lame or[/color][/color][/color]
            ill-worded,[color=blue][color=green][color=darkred]
            > > > or I am asking for something ridiculous perhaps ?
            > > >
            > > > I am still looking for the correct way or a correct way to achieve the
            > > > following:
            > > > I have some JavaScript on a page that produces a couple of variables[/color][/color][/color]
            I'd[color=blue][color=green][color=darkred]
            > > > like to store in a db on my web server without having to ask the user[/color][/color][/color]
            to[color=blue][color=green][color=darkred]
            > > > input them manually in a form again. (would be rather silly)
            > > > How should I do this ? Am I missing something very obvious ?[/color]
            > >
            > > You could send the data over to another php script in a separate window
            > > via a GET request...
            > >
            > > 1. generate the values
            > > 2. use window.open
            > > 3. process you php script, then send a window.close via javascript so
            > > the window disappears.
            > >
            > > However, how well this will work because of popup blockers. Of course,
            > > you could just re-request the page with the GET vars in it when the
            > > value has been calculated...[/color]
            >
            > Or...
            > Instead of a whole new window...
            > Have js create a frame inside of the current page.
            > Set the HREF to:[/color]
            http://your_url.com/variableStore.p hp?variable_1=' whatever'&varia ble_2='anotherW hatever'[color=blue]
            >
            > Then:
            > variableStore.p hp ::
            > <?php
            > // $variable_1 and $variable_2 are now available for manipulation
            > // Put whatever database connectivity you need here.
            > // REMEBER: Do NOT echo, print, or anything else that outputs to the
            > screen
            > // Or else your little frame might show it.
            > ?>
            >
            > The <frame> that holds the variableStore.p hp file could have an OnLoad
            > event that triggers... waits 30 seconds... the REMOVES the <frame> tag
            > from the page. Harder for the user to find out what you did that
            > way...
            >
            > Good luck..[/color]

            Or simply keep around an invisible IFRAME .

            <iframe name="hidden_fo rm" src="/data_collect.ph p" style="display:
            none"><iframe>

            The iframe page would have a form with a number of fields (these don't need
            to be hidden since the frame itself is invisible). Set these fields and
            submit the form using Javascript .


            Comment

            • Pjotr Wedersteers

              #7
              Re: Javascript var to php script

              drwxr-xr-x wrote:[color=blue]
              > On Fri, 16 Jul 2004 03:39:53 +0200, Pjotr Wedersteers hath writ:[color=green]
              >> Sorry to have to ask again, but my ISP's server has some issues I
              >> think, almost anything on this ng dating before 12th of this month
              >> is no longer available all of a sudden. And I don't think I got an
              >> answer to my original post. Not sure if that was because my question
              >> was very lame or ill-worded, or I am asking for something ridiculous
              >> perhaps ?[/color]
              >
              > And, you did not think to check
              > via:
              >
              > http://groups.google.com/advanced_group_search?num=10
              >
              > ?[/color]

              To be honest I did, and got no results. But now it is a different story, I
              guess I must have made a typo in one of the search keys.
              I always check old news first before I submit a question. But thanks for
              your reply!
              Pjotr


              Comment

              • Pjotr Wedersteers

                #8
                Re: Javascript var to php script

                Chung Leong wrote:[color=blue]
                > "Brian Scott O'keefe" <randomblink@ya hoo.com> wrote in message
                > news:5ec923cc.0 407161145.11466 7f@posting.goog le.com...[color=green]
                >> Justin Koivisto <spam@koivi.com > wrote in message[/color]
                > news:<yEQJc.198 $jz4.9668@news7 .onvoy.net>...[color=green][color=darkred]
                >>> Pjotr Wedersteers wrote:
                >>>
                >>>> Sorry to have to ask again, but my ISP's server has some issues I
                >>>> think, almost anything on this ng dating before 12th of this month
                >>>> is no longer available all of a sudden. And I don't think I got an
                >>>> answer to my original post. Not sure if that was because my
                >>>> question was very lame or ill-worded, or I am asking for something
                >>>> ridiculous perhaps ?
                >>>>
                >>>> I am still looking for the correct way or a correct way to achieve
                >>>> the following:
                >>>> I have some JavaScript on a page that produces a couple of
                >>>> variables I'd like to store in a db on my web server without
                >>>> having to ask the user to input them manually in a form again.
                >>>> (would be rather silly)
                >>>> How should I do this ? Am I missing something very obvious ?
                >>>
                >>> You could send the data over to another php script in a separate
                >>> window via a GET request...
                >>>
                >>> 1. generate the values
                >>> 2. use window.open
                >>> 3. process you php script, then send a window.close via javascript
                >>> so the window disappears.
                >>>
                >>> However, how well this will work because of popup blockers. Of
                >>> course, you could just re-request the page with the GET vars in it
                >>> when the value has been calculated...[/color]
                >>
                >> Or...
                >> Instead of a whole new window...
                >> Have js create a frame inside of the current page.
                >> Set the HREF to:[/color]
                >[/color]
                http://your_url.com/variableStore.p hp?variable_1=' whatever'&varia ble_2='anotherW hatever'[color=blue][color=green]
                >>
                >> Then:
                >> variableStore.p hp ::
                >> <?php
                >> // $variable_1 and $variable_2 are now available for manipulation
                >> // Put whatever database connectivity you need here.
                >> // REMEBER: Do NOT echo, print, or anything else that outputs to the
                >> screen
                >> // Or else your little frame might show it.[color=darkred]
                >>>[/color]
                >>
                >> The <frame> that holds the variableStore.p hp file could have an
                >> OnLoad event that triggers... waits 30 seconds... the REMOVES the
                >> <frame> tag from the page. Harder for the user to find out what you
                >> did that way...
                >>
                >> Good luck..[/color]
                >
                > Or simply keep around an invisible IFRAME .
                >
                > <iframe name="hidden_fo rm" src="/data_collect.ph p" style="display:
                > none"><iframe>
                >
                > The iframe page would have a form with a number of fields (these
                > don't need to be hidden since the frame itself is invisible). Set
                > these fields and submit the form using Javascript .[/color]

                Thanks to all of you, you have helped me very well. I will try the different
                suggestions and see which is most to my liking or fits my needs best.

                You guys rock!
                Pjotr


                Comment

                Working...