PHP + Radio Buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PHPLOST
Forum Newbie
Posts: 2
Joined: Fri Sep 24, 2010 6:39 am

PHP + Radio Buttons

Post 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)?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP + Radio Buttons

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
PHPLOST
Forum Newbie
Posts: 2
Joined: Fri Sep 24, 2010 6:39 am

Re: PHP + Radio Buttons

Post 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?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP + Radio Buttons

Post by pickle »

It's possible, but you'd need Javascript to do it.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply