Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP in Javascript!! Pls Help

Status
Not open for further replies.

Forri

Programmer
Joined
Oct 29, 2003
Messages
479
Location
MT
Hi all

I would like that a button when clicked will activate a javascript function which will set a $_SESSION[''] variable for me!!

is this possible

Thanks
nick
 
No,

the browser (i.e. Javascript) executes on the local client PC, the PHP scriot runs on a remote server machine. The two could actualy be the same physical machine but the seperation holds true.
 
As ingresman said, no.
In order to set a session variable there must be an exchange of data between the client and server, the form needs to be submitted and some PHP executed.
You can construct a combination of client and server side code that achieves what you want:
1. Make the button "open" a new window which is the PHP script that infuses the session variable into the server's session tracking.
2. The PHP script issues a client side scriptlet that closes the new window.

That's kind of crude, since there will be the new window for a short time, but you could set a text to it befor it closes...
However, the separation between server and client side technology holds always true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top