Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript var to php script

Pjotr Wedersteers
Guest
 
Posts: n/a
#1: Jul 17 '05
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
 
Posts: n/a
#2: Jul 17 '05

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.myformsname.submit();

____________________________________
Wil Moore III, MCP | Integrations Specialist


Justin Koivisto
Guest
 
Posts: n/a
#3: Jul 17 '05

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.
drwxr-xr-x
Guest
 
Posts: n/a
#4: Jul 17 '05

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:

http://groups.google.com/advanced_group_search?num=10

?
Brian Scott O'keefe
Guest
 
Posts: n/a
#5: Jul 17 '05

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.php?variable_1='whatever'&variable_2 ='anotherWhatever'

Then:
variableStore.php ::
<?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.php 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..
Chung Leong
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Javascript var to php script



"Brian Scott O'keefe" <randomblink@yahoo.com> wrote in message
news:5ec923cc.0407161145.114667f@posting.google.co m...[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.php?variable_1='whatever'&variable_2 ='anotherWhatever'[color=blue]
>
> Then:
> variableStore.php ::
> <?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.php 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_form" src="/data_collect.php" 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 .


Pjotr Wedersteers
Guest
 
Posts: n/a
#7: Jul 17 '05

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


Pjotr Wedersteers
Guest
 
Posts: n/a
#8: Jul 17 '05

re: Javascript var to php script


Chung Leong wrote:[color=blue]
> "Brian Scott O'keefe" <randomblink@yahoo.com> wrote in message
> news:5ec923cc.0407161145.114667f@posting.google.co m...[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.php?variable_1='whatever'&variable_2 ='anotherWhatever'[color=blue][color=green]
>>
>> Then:
>> variableStore.php ::
>> <?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.php 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_form" src="/data_collect.php" 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


Closed Thread