I have a PHP (popup) page which is a list of checkboxes.
I'd like to fill in PHP session variables with the checked results
instantly, as soon as a checkbox is checked (or unchecked).
I.E., I don't want to have a Submit button to gather the results,
as the user could just close the popup after making selections,
without hitting the Submit button.
Thus, I was thinking of using Javascript OnClick on each checkbox.
But then, even if I write a Javascript function as the object of the OnClick,
how do I pass an On or Off value to a PHP variable from Javascript,
as the whole purpose is to store the results in a database field from
the PHP variables?
(Be nice if this was a DUH!! answer....)
Any ideas?
Thanks
....Vidya
http://www.webwisesage.com
How do I set a PHP variable from Javascript?
Moderator: General Moderators
There's no reason ajax couldn't call a page that only set a session var passed by get or post and returned true or false if it was successful in setting that... The pop-up would likely need to refresh the parent for the parent to read in the session vars. Granted, something doesn't seem right about the question to me...
-
darryladie
- Forum Commoner
- Posts: 62
- Joined: Thu Mar 02, 2006 6:14 pm
- Location: East Sussex, UK
find an AJAX tutorial and you want to have the following function in your checkboxes (I think):
you would need to define setValue using PHP and DOM. Try: http://www.w3schools.com
Good Luck
Code: Select all
onclick="setValue(this.value)"Good Luck
Thanks, but...
I came up with a better and simple solution.
Simple is always the way-to-go, in my book.
I realized that my whole challenge was to get the
checkbox data even if the user closed the window.
Which is what the user would have to do eventually,
anyways.
So the solution is to have a window without a "close X box".
And instead simulate a close X with a Submit button that looks
like a regular close X button.
Thus, I get the checkboxes data, server-side.
Actually, by a little thought, I also realized that Javascript is client-side
processing, while PHP is server-side processing. So what I wanted
to do was inherently contradictory.
Thanks for your answers.
....Vidya
Simple is always the way-to-go, in my book.
I realized that my whole challenge was to get the
checkbox data even if the user closed the window.
Which is what the user would have to do eventually,
anyways.
So the solution is to have a window without a "close X box".
And instead simulate a close X with a Submit button that looks
like a regular close X button.
Thus, I get the checkboxes data, server-side.
Actually, by a little thought, I also realized that Javascript is client-side
processing, while PHP is server-side processing. So what I wanted
to do was inherently contradictory.
Thanks for your answers.
....Vidya