473,466 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple Radio Button Groups - Please Help! :)

I'm having a problem with multiple radio button groups within a while
loop. I have the page made so it pulls from a database the row values
- one of which is a Y or N value. I have a radio button group for the
Y and N value for each row of the database that gets pulled but only
the last row will populate the value retrieved from the db. I know
that I have to create a unique name for the radio buttons for each row
- but I don't know how to increment the value automatically for each
row... help??

Apr 9 '07 #1
3 3750
Abersparky wrote:
I'm having a problem with multiple radio button groups within a while
loop. I have the page made so it pulls from a database the row values
- one of which is a Y or N value. I have a radio button group for the
Y and N value for each row of the database that gets pulled but only
the last row will populate the value retrieved from the db. I know
that I have to create a unique name for the radio buttons for each row
- but I don't know how to increment the value automatically for each
row... help??
The best way to get help with your code is to post it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 9 '07 #2
How do I get the radio name to automatically increment?? (and by the
way I know I totally butchered the name value that's there lol)

if ($w_row['vis']=='Y') {
print '<input name="{$w_row["comment_id"]}" type="radio" checked
value="Y">';
} else {
print '<input name="{$w_row["comment_id"]}" type="radio" value="Y">';
}

if ($w_row['vis']=='N') {
print '<input name="{$w_row["comment_id"]}" type="radio" checked
value="N">';
} else {
print '<input name="{$w_row["comment_id"]}" type="radio" value="N">';
}

Apr 9 '07 #3
Abersparky wrote:
How do I get the radio name to automatically increment?? (and by the
way I know I totally butchered the name value that's there lol)

if ($w_row['vis']=='Y') {
print '<input name="{$w_row["comment_id"]}" type="radio" checked
value="Y">';
} else {
print '<input name="{$w_row["comment_id"]}" type="radio" value="Y">';
}

if ($w_row['vis']=='N') {
print '<input name="{$w_row["comment_id"]}" type="radio" checked
value="N">';
} else {
print '<input name="{$w_row["comment_id"]}" type="radio" value="N">';
}
You are using single quotes on the print, that will mean that the names
will literally be "{$w_row...}" I think by just glancing at it, but
assuming your comment_id is an INT AUTO_NUMBER PRIMARY KEY then your
code should be fine if you hadn't used single quotes. You don't need to
write your whole INPUT twice, just set a value for 'checked' to be
inserted into the input code, I'd do something like:

$w_row['vis'] == 'Y' ? $checked='checked="checked"' : $checked="";
echo '<input name="comment' . $w_row["comment_id"] . '" type="radio"
' . $checked . ' />';

Or if you don't like the 3step if (tertiary or whatever..) ...

$checked = '';
if ( $w_row['vis'] == 'Y' ) {
$checked='checked="checked"';
}
echo '<input name="comment' . $w_row["comment_id"] . '" type="radio"
' . $checked . ' />';
hope that helps. you should end up with radio's called comment1,
comment2, comment3 etc. depending on your comment_id field's primary key
values.
Apr 9 '07 #4

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

Similar topics

6
by: TheKeith | last post by:
I am doing a form for my site and would like to enable and disable a radio button set depending on whether one of the choices on an outer radio button set is checked. How can I refer to all the...
1
by: Michael Albanese | last post by:
I am developing an application to handle my compay's OSHA reporting requirements. Some of the input criteria are technical and narowly defined, so I was trying to prvide what i call "Context...
15
by: tabonni | last post by:
I want to check each button groups and save the checked value into a 2 dimensional array. But, it doesn't work. Could anyone tell me what's wrong with my code. My code is as follow: <html>...
2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
1
by: Rage Matrix | last post by:
Hi all, I have a small problem with Access radio button groups in VBA. I've got a radio button group called fraSearchMode with three radio buttons in it. At a certain point, I want to see which...
33
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give...
3
by: Amelyan | last post by:
When we want radio button to belong to a group name we say, radio1.GroupName="GroupA". In this case, radio1 will be unselected if another radio button is selected in "GroupA". Is there a way...
2
by: forbes | last post by:
Hi, I have a form that contains multiple groups of checkboxes that act like radio buttons (at the clients insistance). There is one text field that is required and 28 checkbox groups. Here an...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.