Radio button hidden variable

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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Radio button hidden variable

Post by John Cartwright »

Lets say you have a radio button, well you have two of them with the same name.. so you can only choose one of them, is there any way to include a hidden variable depending on which 1 is changed?

for example

radiobutton1 - value 1
radiobutton2 - value 2

if radiobutton1 is selected add value 3
if radiobutton2 is selected add value 4

so now you have value 1 and 3 if radio button 1 is selected
2 and 4 if radiobutton2 is selected

any help ty
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

To do anything with a radio button before it's submitted would mean a client side solution. Though i can't see a need for what you want to do. You know which one was selected once it's posted so you can do anything with the value after it's posted, ie on the server side.
*shrug* ;)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I know it sounds stupid.. but i sort of need to set 2 different variables
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

if necessary, concat the string from two vars and explode it on the other end. prolly easier to just write a switch on the script side though. If this is user input you need to trap, then you can write a quick javascript to update a hidden input on the fly...
Post Reply