RE: how i assign a js variable to a php variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> 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)

with all due respect, there is absolutely nothing you can do better or differently with an hidden input.
I can send and manage a JS var the same way you do via input, except I do not need to search a node, get it, and put it back every time I need to modify that var.

Remote scripting, JSONP, Ajax are ways to do it since ages.

Persistence, if we are talking about refer the variable rather than recreate it, is something not possible with or without the input, 'cause as PHP serialize/unserialize session vars, in JS you can save the var in JSON format and recreate it for each page reload, unless you do not use ajax, 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, you need to update the varialbe status only once on page unload and that's it.

If you want to change a user status step by step you use localStorage, Gears, or other technologies, unless you do jnot want to overload the server with useless requests performed for each operation over the variable.

Regards

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux