473,382 Members | 1,376 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,382 software developers and data experts.

grabbing the value of a radio button (not an asp:radiobuttonlist)

I'm using some standard HTML radio buttons (to allow finer javascript
interaction) on a web page and would like to catch the selected item on
postback. Since they are all ID's uniquely, is there a way to grab only the
selected item's value? Or do I need to write an if/then statement to figure
out which one is selected?

Sample:

<input runat="server" id="radio1" name="category" />
<input runat="server" id="radio2" name="category" />
<input runat="server" id="radio3" name="category" />
<input runat="server" id="radio4" name="category" />
<input runat="server" id="radio5" name="category" />

-Darrel
Nov 19 '05 #1
2 1529
if you add runat="server" then those radiobuttons are not html controls but
server controls, and are already bein posted back to the server so you can
reference them like this.radio1.selected == true

"darrel" <no*****@hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
I'm using some standard HTML radio buttons (to allow finer javascript
interaction) on a web page and would like to catch the selected item on
postback. Since they are all ID's uniquely, is there a way to grab only
the
selected item's value? Or do I need to write an if/then statement to
figure
out which one is selected?

Sample:

<input runat="server" id="radio1" name="category" />
<input runat="server" id="radio2" name="category" />
<input runat="server" id="radio3" name="category" />
<input runat="server" id="radio4" name="category" />
<input runat="server" id="radio5" name="category" />

-Darrel

Nov 19 '05 #2
as the browser only posts back the name/value pair for a selected radio
button. so you need to set a unique value for each one.

<input type=radio id="radio1" name="category" value="1"/>
<input type=radio id="radio2" name="category" value="2"/>
<input type=radio id="radio3" name="category" value="3"/>
<input type=radio id="radio4" name="category" value="4"/>
<input type=radio id="radio5" name="category" value="5"/>

if radio2 is selected the browser will post category=2. you can check in the
selected value in the code behind by check Request.Form["category"]. it will
equal the value of the selected radio button.

-- bruce (sqlwork.com)
"darrel" <no*****@hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
I'm using some standard HTML radio buttons (to allow finer javascript
interaction) on a web page and would like to catch the selected item on
postback. Since they are all ID's uniquely, is there a way to grab only
the
selected item's value? Or do I need to write an if/then statement to
figure
out which one is selected?

Sample:

<input runat="server" id="radio1" name="category" />
<input runat="server" id="radio2" name="category" />
<input runat="server" id="radio3" name="category" />
<input runat="server" id="radio4" name="category" />
<input runat="server" id="radio5" name="category" />

-Darrel

Nov 19 '05 #3

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

Similar topics

1
by: Jay | last post by:
I need to validate 21 sets of radio buttons before submission to the server for calculation and storage. Is it best to validate on the client side using javascript or to validate on the server...
4
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater...
5
by: Utada P.W. SIU | last post by:
<asp:RadioButtonList></asp:RadioButtonList> only allow create a vertical radion button list how can I use it to create a horizatial radio button list? thanks~
2
by: Alphonse Giambrone | last post by:
Hi all, I have two radiobuttonlist controls on a page. When a user checks 'No' for rblDeleted, I want to automatically set rblSendCard to 'No' and disable it. The javascript function I wrote to...
2
by: dhnriverside | last post by:
Hi guys I want to created a Radio Button List, but because of the formatting I want to perform, I can't use asp:RadioButtonList. Is there a way to link asp:RadioButtons like there is with...
2
by: Michael Bohman | last post by:
Hi, i have a small problem with assigning a database value to a RadioButtonList control. On my form i have 3 user admin=1, premium=2 and basic=3, theese values is stored in an access database in a...
2
by: dancer | last post by:
Using VB2005 and Asp.Net How do I make a variable from an Asp: radio button? I know how to do it from a asp:text box. Here is my control: <asp:RadioButtonList id=EmpCaution runat="server">...
0
by: dancer | last post by:
Can somebody tell me why my RequiredFieldValidator works for the TEXT BOX, (location) but does NOT work for the RADIO BUTTON (EmpTrain)? <%@ Page Language="VB" ClientTarget="downlevel" %> ...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.