i'm new here in this list. guys i need a help. i can't assign a js variable
value to a php variable. how can i do this?
--
Regards,
Saeed Ahmed
Rajshahi, Bangladesh
Blog: http://saeed05.wordpress.com
--
Follow Me Linkedin Twitter
--0016364ed7d05ad5d10473cad95e--
Re: how i assign a js variable to a php variable
am 17.09.2009 21:18:54 von Ashley Sheridan
On Fri, 2009-09-18 at 02:16 +0700, saeed ahmed wrote:
> hello guys,
>
> i'm new here in this list. guys i need a help. i can't assign a js variable
> value to a php variable. how can i do this?
>
>
> --
> Regards,
> Saeed Ahmed
> Rajshahi, Bangladesh
> Blog: http://saeed05.wordpress.com
> --
> Follow Me Linkedin
> Twitter
You can't. Javascript is executed in the browser, PHP is executed on the
server.
What are you trying to achieve, as maybe there is a better way to do it.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: how i assign a js variable to a php variable
am 17.09.2009 21:33:06 von HallMarc Websites
> -----Original Message-----
> From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk]
> Sent: Thursday, September 17, 2009 3:19 PM
> To: saeed ahmed
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] how i assign a js variable to a php variable
>
> On Fri, 2009-09-18 at 02:16 +0700, saeed ahmed wrote:
> > hello guys,
> >
> > i'm new here in this list. guys i need a help. i can't assign a js
> variable
> > value to a php variable. how can i do this?
> >
> >
> > --
> > Regards,
> > Saeed Ahmed
> > Rajshahi, Bangladesh
> > Blog: http://saeed05.wordpress.com
> > --
> > Follow Me Linkedin
> > Twitter
>
> You can't. Javascript is executed in the browser, PHP is executed on
> the
> server.
>
> What are you trying to achieve, as maybe there is a better way to do
> it.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
I have to disagree Ash, you can pass js variable values to PHP but only
through a page load. Then you could use $_REQUEST, $_POST, $_GET to retrieve
it. I have done this before.
[HallMarc Websites]
__________ Information from ESET Smart Security, version of virus signature
database 4434 (20090917) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> I have to disagree Ash=2C you can pass js variable values to PHP but only
> through a page load. Then you could use $_REQUEST=2C $_POST=2C $_GET to r=
etrieve
> it. I have done this before.
And I am sure Ash does it on daily basis=2C the problem is the used therm: =
I want to *assign* ... not pass=2C assign!
I am quite sure that is what he meant=2C since I cannot count people readin=
g in the middle of the page thinking it can interact directly with=
nodes and javascript=2C and being "a new one"=2C I think Ash replied in th=
e correct way.
Regards
____________________________________________________________ _____
Share your memories online with anyone you want.
http://www.microsoft.com/middleeast/windows/windowslive/prod ucts/photos-sha=
re.aspx?tab=3D1=
--_4c51fef6-15b2-4a3e-b1c5-781e94282fb8_--
Re: how i assign a js variable to a php variable
am 18.09.2009 00:36:35 von Phred White
On Sep 17, 2009, at 2:43 PM, Andrea Giammarchi wrote:
>
>
>> I have to disagree Ash, you can pass js variable values to PHP but
>> only
>> through a page load. Then you could use $_REQUEST, $_POST, $_GET to
>> retrieve
>> it. I have done this before.
>
> And I am sure Ash does it on daily basis, the problem is the used
> therm: I want to *assign* ... not pass, assign!
>
> I am quite sure that is what he meant, since I cannot count people
> reading in the middle of the page thinking it can interact
> directly with nodes and javascript, and being "a new one", I think
> Ash replied in the correct way.
>
> Regards
>
All true, and probably appropriate to clarify the relationship between
php and js.
However, if the goal is to pre-set something in php land so you don't
have to pass it with your next page navigation, you could use ajax to
to pass the value to a simple php script that in turn updates a php
session variable, so that it is already set when you do your next real
page load.
You would still be "calling a page" technically, but your current
displayed page would remain in place and php would have the value
available on its next page load.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: how i assign a js variable to a php variable
am 18.09.2009 03:42:30 von HallMarc Websites
> >> I have to disagree Ash, you can pass js variable values to PHP but
> >> only
> >> through a page load. Then you could use $_REQUEST, $_POST, $_GET to
> >> retrieve
> >> it. I have done this before.
> >
> > And I am sure Ash does it on daily basis, the problem is the used
> > therm: I want to *assign* ... not pass, assign!
> >
> > I am quite sure that is what he meant, since I cannot count people
> > reading in the middle of the page thinking it can interact
> > directly with nodes and javascript, and being "a new one", I think
> > Ash replied in the correct way.
> >
> > Regards
> >
> All true, and probably appropriate to clarify the relationship between
> php and js.
>
> However, if the goal is to pre-set something in php land so you don't
> have to pass it with your next page navigation, you could use ajax to
> to pass the value to a simple php script that in turn updates a php
> session variable, so that it is already set when you do your next real
> page load.
>
> You would still be "calling a page" technically, but your current
> displayed page would remain in place and php would have the value
> available on its next page load.
>
Very true. I really didn't intend to dismiss everything you said Ash. I
apologize for that. You were absolutely correct in your statement about not
being able to directly assign the value of a javascript variable to a PHP
variable. I just felt that your response would leave the reader to believe
that that wasn't any way to pass the value at all. In my attempt to throw my
two cents in I essentially did the same to your response. I'm afraid I left
some thinking I was dismissing your entire statement. Sorry about that.
Thank you,
Marc Hall
HallMarc Websites
610.446.3346
[HallMarc Websites]
__________ Information from ESET Smart Security, version of virus signature
database 4435 (20090917) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
once changed, you choose how to proceed, maybe executing any other js
funcion that use new value of/for the input, maybe submit the form an take
it from the request in the next page (in the server side, this time).
basicly is use hidden inputs as a container for php variables, and transform
through js.
2009/9/18 Gautam Bhatia
> hello,
>
> You can also try using AJAX technology to communicate with the server
> side code that is your php :).
>
> Regards,
> Gautam Bhatia
> Punjab,India
> mail2gautambhatia@gmail.com
>
>
> On Fri, 2009-09-18 at 02:16 +0700, saeed ahmed wrote:
> > hello guys,
> >
> > i'm new here in this list. guys i need a help. i can't assign a js
> variable
> > value to a php variable. how can i do this?
> >
> >
> > --
> > Regards,
> > Saeed Ahmed
> > Rajshahi, Bangladesh
> > Blog: http://saeed05.wordpress.com
> > --
> > Follow Me Linkedin
> > Twitter
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> basicly is use hidden inputs as a container for php variables=2C and tran=
sform
> through js.
really? I though the other way round was extremely simple:
echo ''=3B
why would you use hidden input=2C plus DOM to get data=2C etc=2C etc?
____________________________________________________________ _____
Show them the way! Add maps and directions to your party invites.=20
http://www.microsoft.com/windows/windowslive/products/events .aspx=
> From: an_red@hotmail.com
> To: jonathan.desarrollo@gmail.com=3B mail2gautambhatia@gmail.com
> CC: saeed.sas@gmail.com=3B php-general@lists.php.net
> Date: Fri=2C 18 Sep 2009 13:01:28 +0200
> Subject: RE: [PHP] how i assign a js variable to a php variable
>=20
>=20
>=20
> > basicly is use hidden inputs as a container for php variables=2C and tr=
ansform
> > through js.
>=20
> really? I though the other way round was extremely simple:
>=20
> echo ''=3B
>=20
> why would you use hidden input=2C plus DOM to get data=2C etc=2C etc?
>=20
> ____________________________________________________________ _____
> Show them the way! Add maps and directions to your party invites.=20
> http://www.microsoft.com/windows/windowslive/products/events .aspx
____________________________________________________________ _____
With Windows Live=2C you can organize=2C edit=2C and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/prod ucts/photo-gall=
ery-edit.aspx=
imagine you have an assoc. array that you encode with json and save in the
js var. Ok.
This way is perfect. But you can do less with this values than using my
solution. Important: Each case is different, and may be studied in
particular.
You can not pass this myPHPvar javascript var as an input in a form. if you
want to change its value and maintein it, must to use an static var, and
only can access to this values via javascript functions where an event is
invoked (in case you want to read or write values)
And I repeat: My solution is not the best, of course, but in many cases (for
my), mantaninance of data in hidden input and using DOM for accessing it,
allow an easiest dinamic treatment of data without reload a web page. Even
more if using jQwey or Prototype.
2009/9/18 Andrea Giammarchi
> Actually, it's even more simple ... forgive me:
>
> echo '';
>
> that's pretty much it
>
> > From: an_red@hotmail.com
> > To: jonathan.desarrollo@gmail.com; mail2gautambhatia@gmail.com
> > CC: saeed.sas@gmail.com; php-general@lists.php.net
> > Date: Fri, 18 Sep 2009 13:01:28 +0200
> > Subject: RE: [PHP] how i assign a js variable to a php variable
> >
> >
> >
> > > basicly is use hidden inputs as a container for php variables, and
> transform
> > > through js.
> >
> > really? I though the other way round was extremely simple:
> >
> > echo '';
> >
> > why would you use hidden input, plus DOM to get data, etc, etc?
> >
> > ____________________________________________________________ _____
> > Show them the way! Add maps and directions to your party invites.
> > http://www.microsoft.com/windows/windowslive/products/events .aspx
>
> ------------------------------
> With Windows Live, you can organize, edit, and share your photos.
>
And of course, sorry for my english!!! I correct!!
Imagine you have an assoc. array that you encode with json and save into the
> js var. Ok.
>
> This way is perfect. But you can do less with this values than using my
> solution. Important: Each case is different, and may be studied in
> particular.
>
> You can not send by request this myPHPvar javascript var as an input in a
> form. if you want to change its value and maintain it, must to use an static
> var, and only can access to this value via javascript functions when an
> event is invoked (in case you want to read or write values)
>
> And I repeat: My solution is not the best, of course, but in many cases
> (for me), data maintainance in hidden inputs, and using DOM to access it,
> allow an easiest dinamic treatment of data without reloading a web page.
> Even more if you are using jQwey or Prototype.
>
>
>
> 2009/9/18 Andrea Giammarchi
>
> Actually, it's even more simple ... forgive me:
>>
>> echo '';
>>
>> that's pretty much it
>>
>> > From: an_red@hotmail.com
>> > To: jonathan.desarrollo@gmail.com; mail2gautambhatia@gmail.com
>> > CC: saeed.sas@gmail.com; php-general@lists.php.net
>> > Date: Fri, 18 Sep 2009 13:01:28 +0200
>> > Subject: RE: [PHP] how i assign a js variable to a php variable
>> >
>> >
>> >
>> > > basicly is use hidden inputs as a container for php variables, and
>> transform
>> > > through js.
>> >
>> > really? I though the other way round was extremely simple:
>> >
>> > echo '';
>> >
>> > why would you use hidden input, plus DOM to get data, etc, etc?
>> >
>> > ____________________________________________________________ _____
>> > Show them the way! Add maps and directions to your party invites.
>> > http://www.microsoft.com/windows/windowslive/products/events .aspx
>>
>> ------------------------------
>> With Windows Live, you can organize, edit, and share your photos.
>>
>
>
> You can not pass this myPHPvar javascript var as an input in a form. if y=
ou
> want to change its value and maintein it=2C must to use an static var=2C =
and
> only can access to this values via javascript functions where an event is
> invoked (in case you want to read or write values)
with all due respect=2C there is absolutely nothing you can do better or di=
fferently with an hidden input.
I can send and manage a JS var the same way you do via input=2C except I do=
not need to search a node=2C get it=2C and put it back every time I need t=
o modify that var.
Remote scripting=2C JSONP=2C Ajax are ways to do it since ages.
Persistence=2C if we are talking about refer the variable rather than recre=
ate it=2C is something not possible with or without the input=2C 'cause as =
PHP serialize/unserialize session vars=2C in JS you can save the var in JSO=
N format and recreate it for each page reload=2C unless you do not use ajax=
=2C but in that case we are talking about synchronization between a client/=
server mirrored variable status.
If you use Ajax for the entire client session=2C you need to update the var=
ialbe status only once on page unload and that's it.
If you want to change a user status step by step you use localStorage=2C Ge=
ars=2C or other technologies=2C unless you do jnot want to overload the ser=
ver with useless requests performed for each operation over the variable.
Regards
____________________________________________________________ _____
Drag n=92 drop=97Get easy photo sharing with Windows Live=99 Photos.
On Fri, 2009-09-18 at 02:16 +0700, saeed ahmed wrote:
> hello guys,
>
> i'm new here in this list. guys i need a help. i can't assign a js variable
> value to a php variable. how can i do this?
>
>
> --
> Regards,
> Saeed Ahmed
> Rajshahi, Bangladesh
> Blog: http://saeed05.wordpress.com
> --
> Follow Me Linkedin
> Twitter
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how i assign a js variable to a php variable
am 19.09.2009 16:15:09 von TedD
At 2:16 AM +0700 9/18/09, saeed ahmed wrote:
>hello guys,
>
>i'm new here in this list. guys i need a help. i can't assign a js variable
>value to a php variable. how can i do this?
saeed:
Considering that js is client-side and php is server-side, you need
to pass the value via a communication mechanism between the two. Your
choices are the standard GET/POST or ajax.