473,765 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
+ 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 3783
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*******@attgl obal.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='check ed="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='check ed="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
4080
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 inputs of the inner radio button set (they all share a common name) with javascript. I tried document.getElementsByNames('thename') but it doesn't work. I know this is because this method returns an array which you must then refer to by a specific...
1
8765
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 Sensitive Help" by providing a short instructional message based on which control has Focus. Because of the way that a Radio Button List control is rendered in the browser i can not attach an onFocus event
15
2123
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> <body> <script language="javascript"> <!-- var temp = new Array(2) var status = new Array();
2
3155
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 they want. If they need to add more, they click an "add name" button and the javascript inserts another row of input boxes. Each row should have two radio buttons to indicate sex (M F). When you have multiple text input boxes with the same...
1
47849
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 radio button is selected and store the value (1, 2 or 3) in a Byte variable. Now, I assumed that this was a simple case of choosing the button you wanted and checking the fraSearchMode.Value property for value 1, 2 or 3. Apparently this is not so....
33
3662
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 me some kind of example on how to do this???? I am doing this in asp.net VB. Please let me know if you need any additional information. Thanks
3
2072
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 (trick, custom RadioButton, or javascript) to make radio button (radio1) belong to 2 independent radio button groups instead of one? This would be an equivalent of sayting something like radio1.GroupName1 = "GroupA"; radio1.GroupName2 = "GroupB";
2
6804
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 example of a checkbox group: <td><input type="checkbox" name="trusted" value="1" id="ck_ttt1" onclick="... <td><input type="checkbox" name="trusted" value="2" id="ck_ttt2"
11
2278
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 6.something I think and running as a service, Using NoteTab Pro as an IDE (works well). If you need more, just ask. In one functioning form:
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10161
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
9833
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...
1
7378
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
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
5275
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...
1
3924
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 we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.