473,771 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2999
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
8177
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 button opens the asp page that returns the result of the calculation. What I would like to do is add certain numbers to the total based on radio buttons or checkboxes that the user activates on the form page. For instance, they enter the numbers into...
1
4107
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 1, the combo box should contains "A", "B", "C" Click Radio Button 2, the combo box should contains "E", "F", "G"
3
43988
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 left hand side corner and on a white background it doesn't show up very well. I've seen multiple examples of radio buttons that are fully outlined in blue and the little dot is green. How the heck do I do this??? I've figured out how to change...
10
13459
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 related to checkboxes. Thanks!!!
3
2823
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 code below works in mac/win firefox, other browsers don't handle it at all. I have tried using onclick, and that buggers it in all browsers. <script type="text/javascript"> function updateSize()
18
3351
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 columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information from the dataset and how can I do that? Also, I set the property of the listbox to selectionmode...
24
4567
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 resources and memory - both appear to be in order. Can anyone comment on this? Should CreateDialogIndirect() which is located in dlgcore.cpp ever fire a button click routine??
1
5816
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 javascript gives me three alerts for each of them. In other words all three of them have at least one element checked and so I get three alerts with the below code. var ips = document.getElementsByTagName('input'); for(i=0; i<ips.length; i++) {...
6
2075
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 />"; The post_data.php program posts the following member id is: 0009
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.