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.
easy question about radio buttons
Collapse
X
-
Tags: None
-
Originally posted by html on wheelsGreeting 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.Code:<br />
-
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.Comment
-
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="checke d" /> 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>Comment
-
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="checke d" /> 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.Comment
-
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.Comment
-
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="checke d" /> 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>Comment
-
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.Comment
-
Originally posted by drhowarddrfineWhile 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.
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("c ategory")
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.Comment
-
What language is this, jhardman?
myVar = request.form("c ategory")
Didn't take you very long to leave me in the dust.Comment
-
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?Comment
-
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.Comment
Comment