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

easy question about radio buttons

html on wheels
Greeting sports fans. In order to ask multiple questions and not have your radio buttons jump from one question to the next, what do you type to create a break between them. I am trying to complete a user document but the radio buttons do not function per each individual sentence. Instead, all of the radio buttons are linked up. I could write the code if anybody is still confused about my question as I am finding it hard to explain this. In other words, if you click "I disagree in question 2, the radio buttons in question 1 are blank. This has to be simple, but I can't figure it out.
Feb 13 '07 #1
12 2520
AricC
1,892 Expert 1GB
Greeting sports fans. In order to ask multiple questions and not have your radio buttons jump from one question to the next, what do you type to create a break between them. I am trying to complete a user document but the radio buttons do not function per each individual sentence. Instead, all of the radio buttons are linked up. I could write the code if anybody is still confused about my question as I am finding it hard to explain this. In other words, if you click "I disagree in question 2, the radio buttons in question 1 are blank. This has to be simple, but I can't figure it out.
By break between them do you mean a new line? Use
Expand|Select|Wrap|Line Numbers
  1. <br />
Feb 13 '07 #2
drhowarddrfine
7,435 Expert 4TB
You just have to make sure the radio buttons are only part of the form associated with each question. I'm running out the door, sorry.
Feb 13 '07 #3
I mean this:

1. Violets are red
O I agree
O I disagree

2. Violets are blue
O I agree
O I disagree

If I click the radio button for I agree in #2, the radio button in #1 disappears. I this this was the following code I used.

<html>
<body>
<ol>
<li>Violets are red<br />
<input type="radio" name="category" value="I agree" checked="checked" /> I agree<br />
<input type="radio" name="category" value="I disagree" /> I disagree<br />
<li>VIolets are blue<br />
<input type="radio" name="category" value="I agree" /> I agree<br />
<input type="radio" name="category" value="I disagree" /> I disagree<br /></li><ol>
</body>
</html>
Feb 13 '07 #4
drhowarddrfine
7,435 Expert 4TB
Like I said, you need to keep the input items in their own form:

<html>
<body>
<ol>
<li>Violets are red<br /><form>
<input type="radio" name="category" value="I agree" checked="checked" /> I agree<br />
<input type="radio" name="category" value="I disagree" /> I disagree<br /></form></li>
<li>VIolets are blue<br /><form>
<input type="radio" name="category" value="I agree" /> I agree<br />
<input type="radio" name="category" value="I disagree" /> I disagree<br /></form></li><ol>
</body>
</html>

But you need to read up on the form attributes.
Feb 13 '07 #5
Thanks a million. I was not familiar with the <form> tag, and the book I was reading from did not address multiple questions with radio buttons. If you're running for mayor any time soon, you just got my vote.
Feb 13 '07 #6
jhardman
3,406 Expert 2GB
Doesn't it make more sense to split the input than the form?

<html>
<body>
<ol>
<li>Violets are red<br />
<input type="radio" name="category1" value="I agree" checked="checked" /> I agree<br />
<input type="radio" name="category1" value="I disagree" /> I disagree<br /></li>
<li>VIolets are blue<br />
<input type="radio" name="category2" value="I agree" /> I agree<br />
<input type="radio" name="category2" value="I disagree" /> I disagree<br /></li><ol>
</body>
</html>
Feb 13 '07 #7
drhowarddrfine
7,435 Expert 4TB
While that may appear to make sense, it doesn't work. The form element is used to contain the different control elements into the same group, just like a div can contain it's own <p> and other block elements.
Feb 13 '07 #8
TNT
48
You could try using
[HTML]<fieldset>
<legend>...Group title...legend>
...radio buttons...
</fieldset>[/HTML]
Feb 15 '07 #9
jhardman
3,406 Expert 2GB
While that may appear to make sense, it doesn't work. The form element is used to contain the different control elements into the same group, just like a div can contain it's own <p> and other block elements.
I think I'm confused now. I can't think of any time I've used multiple groups of radio buttons in a single form, but I thought my example would post a single form with inputs:
category1="I agree"
category2="I disagree"
doesn't yours send two different forms? How are the inputs sent to the receiver, and how do you access them? Do you need to refer to different form names? You obviously can't just say:
myVar = request.form("category")
because that wouldn't distinguish between the two inputs. It would probably just give you the second. Right? (maybe an array?)

I get the feeling you are more of an HTML purist than I, so maybe I'm just being sloppy. Like I said, I've never tried this, but I sure wouldn't have thought to try it your way.
Feb 15 '07 #10
What language is this, jhardman?

myVar = request.form("category")

Didn't take you very long to leave me in the dust.
Feb 15 '07 #11
jhardman
3,406 Expert 2GB
sorry, I spend more time in the ASP forum.

I always send my forms to ASP pages, coded in vbscript. The I can save the form inputs to text files or email them, or whatever. Where do you send your form as it is now? How does that file handle the inputs?
Feb 16 '07 #12
drhowarddrfine
7,435 Expert 4TB
jhardman,
He is asking how to do radio buttons in html so he gets an html answer. The inputs are simply posted to the server by the browser when submitted. What happens after that depends on the language and server he uses. What we are doing is what ASP does for you although, perhaps, it uses more javascript than I might.
Feb 16 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
4
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>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
3
by: Ken Varn | last post by:
This is probably a simple question, but I am new to this so bear with me. I have a ASP.NET form that has a checkbox and a 2 radio buttons. When the checkbox is checked, the 2 radio buttons are...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
1
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
4
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...

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.