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

Home Posts Topics Members FAQ

Loop through a Plain Radio Button in ASP.NET

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

Nov 19 '05 #1
33 3662
If they are plain HTML radio buttons, you can't loop through them in
server-side code. It must be done from client-side code.
"Brian" <bc******@pepeh azard.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
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

Nov 19 '05 #2
Can you elaborate on looping through radio buttons?

If the radio buttons are defined by you, why do you need to loop
through them after submission? And you can select only one item in a
radiobutton-group.

Can you give an example of what you are trying to achieve? That may
help in analysing the problem better.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #3
to get most of the help in this group, you better post a try of ur code.
asking plain questions like this usually is missleading or says that you
haven't tried anything in the first place.
why don't u try to do it in ur own code and post ur code so u can have
better guidance. i hope u find the answer as soon as possible ;)
"Brian" <bc******@pepeh azard.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
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

Nov 19 '05 #4
Thanks for the replies.... Ok.. I have 8 groups of questions. I'll post
a sample of one group below. Depending on who logs in, will depend on
how many groups of questions they will get. Once they check either the
yes or no radio button for each question, the will submit the form. I
will need to know how many questions there are, then loop through those
questions and input them into the db. for example( if two of the
questions were "the sky is blue" and "the ocean is green".. One record
will be created for the first question, and another record will be
created for the second question). I also need to know if any answers
were answered yes, but that is a separate issue. Right now, I just need
to know how to do this part... Here is a sample of the questions. These
are being stored in a questions table in the db.
-------------------------------------------------

<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<th noWrap>
<div align="center"> <span class="style3"> Coronary Artery Disease
</span></div></th>
<th><span class="style3"> YES</span></th>
<th><span class="style3"> NO</span></th></tr>
<tr>
<td noWrap width="69%"><sp an class="style3"> Have you ever received a
diagnosis of heart disease or coronary artery disease?</span></td>
<td width="6%">
<div align="center">
<input type="radio" value="yes" name="CAD_1" /> </div></td>
<td width="6%">
<div align="center">
<input type="radio" value="no" name="CAD_1" /> </div></td></tr>
<tr>
<td class="style3" noWrap>Have you ever had a heart attack?</td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_2" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_2" /> </div></td></tr>
<tr>
<td class="style3" noWrap>Have you ever been treated for a blocked atery
anywhere in your body? </td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_3" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_3" /> </div></td></tr>
<tr>
<td class="style3" noWrap><span class="style4"> Have you ever been
treated for chest pain caused by blockage of arteries in your heart?
</span></td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_4" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_4" /> </div></td></tr>
<tr>
<td class="style3" noWrap><span class="style4"> Have you ever had an
abnormal exercise tolerance test (ETT, stress test) </span></td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_5" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_5" />
</div></td></tr></tbody></table>

-------------------------------------------------

I am just querying the db and grabbing the appropriate groups.. The
names of the radios are important too, per the customers request.
Another group would be CHF_1,CHF_2, etc.. If anyone knows a better way
of doing this, I'll be glad to hear it... Let me know if you need
anymore detail..

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #5
If there are only 8 questions (and each radio button in a group are all
named the same name), you don't need to loop at all. Just check all 8
groups to see if a group has a value. If a group has a value, then that
question was responded to.

Or, since they are submitting the data to the server, you could just check
the Request object in the same way to see what data was submitted.
"Brian Ciarcia" <bc******@pepeh azard.com> wrote in message
news:e%******** ********@tk2msf tngp13.phx.gbl. ..
Thanks for the replies.... Ok.. I have 8 groups of questions. I'll post
a sample of one group below. Depending on who logs in, will depend on
how many groups of questions they will get. Once they check either the
yes or no radio button for each question, the will submit the form. I
will need to know how many questions there are, then loop through those
questions and input them into the db. for example( if two of the
questions were "the sky is blue" and "the ocean is green".. One record
will be created for the first question, and another record will be
created for the second question). I also need to know if any answers
were answered yes, but that is a separate issue. Right now, I just need
to know how to do this part... Here is a sample of the questions. These
are being stored in a questions table in the db.
-------------------------------------------------

<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<th noWrap>
<div align="center"> <span class="style3"> Coronary Artery Disease
</span></div></th>
<th><span class="style3"> YES</span></th>
<th><span class="style3"> NO</span></th></tr>
<tr>
<td noWrap width="69%"><sp an class="style3"> Have you ever received a
diagnosis of heart disease or coronary artery disease?</span></td>
<td width="6%">
<div align="center">
<input type="radio" value="yes" name="CAD_1" /> </div></td>
<td width="6%">
<div align="center">
<input type="radio" value="no" name="CAD_1" /> </div></td></tr>
<tr>
<td class="style3" noWrap>Have you ever had a heart attack?</td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_2" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_2" /> </div></td></tr>
<tr>
<td class="style3" noWrap>Have you ever been treated for a blocked atery
anywhere in your body? </td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_3" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_3" /> </div></td></tr>
<tr>
<td class="style3" noWrap><span class="style4"> Have you ever been
treated for chest pain caused by blockage of arteries in your heart?
</span></td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_4" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_4" /> </div></td></tr>
<tr>
<td class="style3" noWrap><span class="style4"> Have you ever had an
abnormal exercise tolerance test (ETT, stress test) </span></td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_5" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_5" />
</div></td></tr></tbody></table>

-------------------------------------------------

I am just querying the db and grabbing the appropriate groups.. The
names of the radios are important too, per the customers request.
Another group would be CHF_1,CHF_2, etc.. If anyone knows a better way
of doing this, I'll be glad to hear it... Let me know if you need
anymore detail..

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #6
Actually, it is 8 groups of questions and the names are different..
(ie.. group one.. the names are CAD_1,CAD_2,CAD _3 group two.. the names
are CHF_1,CHF_2,CHF _3,CHF_4. etc..) Each group has a different number
of questions. Each question has to have an answer, either yes or no..
Since this is an asp.net page, I have no clue How to get the answers
into the database. CAD_1 has to have its own record, CAD_2 has to have
its own record, etc, etc.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #7
try to put the group of radio buttons in a web control PlaceHolder, make
those radio buttons Web controls instead of HTML in that PlaceHolder.

then you can use :

foreach( Control c in placeHolder.Con trols )
{
//cast the control to web radio button and do what ever u like with it
}

i hope this helps
"Brian Ciarcia" <bc******@pepeh azard.com> wrote in message
news:e%******** ********@tk2msf tngp13.phx.gbl. ..
Thanks for the replies.... Ok.. I have 8 groups of questions. I'll post
a sample of one group below. Depending on who logs in, will depend on
how many groups of questions they will get. Once they check either the
yes or no radio button for each question, the will submit the form. I
will need to know how many questions there are, then loop through those
questions and input them into the db. for example( if two of the
questions were "the sky is blue" and "the ocean is green".. One record
will be created for the first question, and another record will be
created for the second question). I also need to know if any answers
were answered yes, but that is a separate issue. Right now, I just need
to know how to do this part... Here is a sample of the questions. These
are being stored in a questions table in the db.
-------------------------------------------------

<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<th noWrap>
<div align="center"> <span class="style3"> Coronary Artery Disease
</span></div></th>
<th><span class="style3"> YES</span></th>
<th><span class="style3"> NO</span></th></tr>
<tr>
<td noWrap width="69%"><sp an class="style3"> Have you ever received a
diagnosis of heart disease or coronary artery disease?</span></td>
<td width="6%">
<div align="center">
<input type="radio" value="yes" name="CAD_1" /> </div></td>
<td width="6%">
<div align="center">
<input type="radio" value="no" name="CAD_1" /> </div></td></tr>
<tr>
<td class="style3" noWrap>Have you ever had a heart attack?</td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_2" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_2" /> </div></td></tr>
<tr>
<td class="style3" noWrap>Have you ever been treated for a blocked atery
anywhere in your body? </td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_3" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_3" /> </div></td></tr>
<tr>
<td class="style3" noWrap><span class="style4"> Have you ever been
treated for chest pain caused by blockage of arteries in your heart?
</span></td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_4" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_4" /> </div></td></tr>
<tr>
<td class="style3" noWrap><span class="style4"> Have you ever had an
abnormal exercise tolerance test (ETT, stress test) </span></td>
<td>
<div align="center">
<input type="radio" value="yes" name="CAD_5" /> </div></td>
<td>
<div align="center">
<input type="radio" value="no" name="CAD_5" />
</div></td></tr></tbody></table>

-------------------------------------------------

I am just querying the db and grabbing the appropriate groups.. The
names of the radios are important too, per the customers request.
Another group would be CHF_1,CHF_2, etc.. If anyone knows a better way
of doing this, I'll be glad to hear it... Let me know if you need
anymore detail..

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #8
Im sorry.. I'm really ignorant when it comes to this... How do I put it
in a placeholder? can I still store the groups in the database?? I
feel like such an idiot now..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #9
you are not idiot at all, all what you need is more reading. go to the msdn
and read more about the place holder :)
"Brian Ciarcia" <bc******@pepeh azard.com> wrote in message
news:eg******** ******@TK2MSFTN GP14.phx.gbl...
Im sorry.. I'm really ignorant when it comes to this... How do I put it
in a placeholder? can I still store the groups in the database?? I
feel like such an idiot now..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #10

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

Similar topics

4
3281
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1> <input type="radio" name=p2 value=2> <input type="radio" name=p2 value=3> then a text area and a button:
6
1679
by: Ed Jay | last post by:
<disclaimer>New to js.</disclaimer> I have several pages, each with menues comprising checkboxes or radio boxes within the same form. I presently 'brute force' clear the buttons with individual scripts for each form, e.g.: function clearLa() { window.document.form1.button1La.checked=false; window.document.form1.button2La.checked=false; window.document.form1.button3La.checked=false;
9
9305
by: wreed | last post by:
I have a for loop seen below.... var the_form = document.getElementById(formName); for(var i=0; i<the_form.length; i++) { var temp = the_form.elements.type; if (temp == "radio") { for (x = 0; x < the_form.elements.length - 1; x++) {
9
2254
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script type="text/javascript"> function setCheckedValue(radioObj, newValue) { if(!radioObj)
10
6104
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
8
6767
by: romano2717 | last post by:
I used the for loop variable $i to each radio button so that each radio button will have a unique name. the problem now is how can i display the values selected in the radio button on the same page as where the form is located. your help is greatly appreciated.. thanks here's the code: NOTE: this code is cut short, i only posted the part where i got stuck <?php if(isset($_GET)){ $num = $_GET; $num = 2; for($i=1; $i<=$num; $i++...
2
21499
by: somacore | last post by:
VS2005, C# Windows Form I can't quite figure out how to do this, but i think I'm close. I have a groupbox which contains 8 radio buttons, and I need to figure out which one is checked for entry into a database. The button field looks like this: ()Assigned ()Working ()In Testing and so on. In the DB, the values of the checkboxes are treated as an int, 0, 1, 2, 3 etc.
0
9619
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
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
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
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...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.