473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How do I display radio button results?

I have a form which uses several radio buttons to enter data. It works fine
as far as entering goes, but I can't figure out how to display which button
is checked when I view the record. I could do a if-then routine but it
seems like there should be an easier way.

Any help will be greatly appreciated.
Oct 30 '06 #1
1 2970
Bob Sanderson wrote:
I have a form which uses several radio buttons to enter data. It works fine
as far as entering goes, but I can't figure out how to display which button
is checked when I view the record. I could do a if-then routine but it
seems like there should be an easier way.

Any help will be greatly appreciated.
What's your HTML like and how are you dealing with it in PHP?

This (with possible unintended errors corrected) works:

<!-- HTML, assume correct DOCTYPE, ... -->
<form ...>
<div class="group1">
<label><input type="radio" name="r[0]" value="0" checked>none</label>
<label><input type="radio" name="r[0]" value="1">one</label>
<label><input type="radio" name="r[0]" value="1">two</label>
</div>
<div class="group2">
<label><input type="radio" name="r[1]" value="0" checked>none</label>
<label><input type="radio" name="r[1]" value="1">one</label>
<label><input type="radio" name="r[1]" value="1">two</label>
</div>
<!-- some submit button -->
</form>

And the PHP that deals with it could be

<?php
foreach ($_POST['r'] as $k=>$radio) {
echo 'For group ', $k, ', you selected the option with ',
$radio, " for its value.<br>\n";
}
?>

--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Oct 30 '06 #2

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

Similar topics

2
by: Newbie | last post by:
I currently have a set of simple calculations to determine square footage and multuply that by a dollar amount per foot. I use form fields that are filled in by the user, and then the Submit...
1
by: David | last post by:
Hi, May I know how to create data dynamically in a combo box after clicking on a radio button ? Data are retrieved using a store procedure from a SQL Server. For example : Click Radio Button...
3
by: NONYA | last post by:
This is driving me crazy. I'm having trouble with how a simple radio button is displayed, in a simple html form. The default has the outline around the radio button shaded gray only in the top...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
3
by: chuck | last post by:
Hi, This is a test for a larger form i am working on. I want to have a real time display of the radio button value when selected. I tried with various event handlers with varying success. The...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
24
by: John Gabriel | last post by:
CreateDialogIndirect() fires my Radio button click function without the radio button having being clicked. I am using VC++ 2003.NET. I believe this is yet another Microsoft bug. Have checked dialog...
1
by: querry | last post by:
`Hi all, I am trying to get the selected radio button item in a radio button list using javascript. I am successful at doing this, but the problem is I have several Radio Button Lists, and the...
6
by: dba | last post by:
using the following code with a problem.... echo "<input type='hidden' name='member_id' value=\"{$row}\">{$row}"; echo "<input type='radio' name='member_name' value=\"{$row}\">{$row}<br />"; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...

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.