By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

easy question about radio buttons

html on wheels
P: 35
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
Share this Question
Share on Google+
12 Replies


Expert 100+
P: 1,892
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
Expert 5K+
P: 7,435
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

html on wheels
P: 35
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
Expert 5K+
P: 7,435
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

html on wheels
P: 35
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
Expert 2.5K+
P: 3,405
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
Expert 5K+
P: 7,435
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
P: 48
TNT
You could try using
[HTML]<fieldset>
<legend>...Group title...legend>
...radio buttons...
</fieldset>[/HTML]
Feb 15 '07 #9

jhardman
Expert 2.5K+
P: 3,405
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

html on wheels
P: 35
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
Expert 2.5K+
P: 3,405
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
Expert 5K+
P: 7,435
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

Post your reply

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