473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Radio buttons anf IF statements

On a form, i have
<label><input name="radiogroup" type="radio" value="Technical">
Technical</label>
<label><input name="radiogroup" type="radio" value="Admin">
Administrative</label>
<label><input name="radiogroup" type="radio" value="Site">
Web-Site</label>
<label><input name="radiogroup" type="radio" value="General"
checked>
General</font></dd></label>

then on another form i want an if statement
like
if ($radiogroup=="Admin")
{
$contact="email address";
$subject="subject"l
else
{
$contact="anotheremailaddress";
$subject="anothersubject";

Is this correct, or how do i do an if statement including depending on what
radio button is checked?

thanks
--
Kathryn (Fire Juggler)
http://www.firejugglers.34sp.com
http://www.cornwalljugglers.co.uk
Jul 17 '05 #1
1 3301
*** Fire Juggler wrote/escribió (Tue, 22 Mar 2005 14:47:55 -0000):
if ($radiogroup=="Admin")
{
$contact="email address";
$subject="subject"l
else
{
$contact="anotheremailaddress";
$subject="anothersubject";

Is this correct, or how do i do an if statement including depending on what
radio button is checked?


It's not portable since you're assuming that form variables will be
imported as local variables. which is often not the case. Also, a switch
normally provides clearer code in situations like this.

<?

switch($_POST['radiogroup']){ // Use $_GET if method="get"
case 'Admin':
$contact=......;
$subject=......;
break;

case 'Site':
$contact=......;
$subject=......;
break;

case 'General':
$contact=......;
$subject=......;

default:
$contact='';
$subject='';
}

?>

--
-- Álvaro G. Vicario - Burgos, Spain
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: amith | last post by:
hi, i have some 10 radio buttons meant to take the rating from the user. ex: 1 2 3 4 5 6 7 8 9 10 looks O O O O O O O O O O 1 2 3 4 5 6 7 8 9 10 features O O O O O O O O O O
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
16
by: Stuart | last post by:
I have a page where I utilise the left and right cursor keys to change an image, also on this page is a groups of radio buttons, unfortunately when a radio button is clicked the focus for the...
7
by: Milo333 | last post by:
Hi Please help, how do i write an if statement to check through 4 radio buttons, if none of the 4 buttons are selected than a message box must popup saying incomplete form, please complete the...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
4
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
4
by: Z.K. | last post by:
I started a forms application and I put on the form three buttons. In the functions for the radio buttons I put in a single messagebox like: MessageBox("Hello 1") MessageBox("Hello 2") ...
2
by: zigerati | last post by:
New to programming and am struggling on the following: I've got a repeater that dynamically creates a series of questions. The questions come from a database and can be either answertype 1 or 2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.