Page 1 of 1
PHP + Radio Buttons
Posted: Fri Sep 24, 2010 6:44 am
by PHPLOST
I have a table that is dynamically filled with data from a mysql database using a for loop. The first table cell in each row that is displayed has a radio button with a unique value, and a unique id based on the counter of the loop. When the use selects one of the radio buttons, is there a way that I can store that value into a session variable to be used on the next few pages (without having the table in a form)?
Re: PHP + Radio Buttons
Posted: Fri Sep 24, 2010 9:52 am
by pickle
You can tie the clicking of the radio button to an AJAX call that sends the data to the server to be stored in $_SESSION.
Unless you're doing other AJAX-y things on this page, I can't think of a reason why you'd need to record which radio was clicked, before submitting the form.
Re: PHP + Radio Buttons
Posted: Fri Sep 24, 2010 10:39 am
by PHPLOST
The value doesnt need to be stored until the user clicks one of the buttons further down on the page which navigates them to a different page. Is it possible to take the value of the selected radio button without the radio button being in a form?
Re: PHP + Radio Buttons
Posted: Fri Sep 24, 2010 10:43 am
by pickle
It's possible, but you'd need Javascript to do it.