Jump to content


Photo

Radio buttons and for loops


  • Please log in to reply
2 replies to this topic

#1 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 September 2006 - 06:31 AM

Hi Guys,
I'm dynamically creating a group of radio buttons with PHP, and am trying to loop through them and get the value of the selected radio button. This appears to be working fine with more than one radio button, although it doesn't appear to enter the loop if there is only one radio button. I can't figure this out, any ideas?

EDIT: For some reason I can't post my code up here. I have uploaded it here

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 September 2006 - 07:01 AM

It always helps by asking a question and writing a demo script as that's when I generally figure out the problem after staring at it for an hour or so!

Turns out, if there is only one radio button in a group, it is not defined as an array with a single key, but instead just a normal variable.

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 04:03 AM

I always cheat by handling this first, and forcing it into an array no matter what.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users