easy question about radio buttons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • html on wheels
    New Member
    • Feb 2007
    • 35

    easy question about radio buttons

    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.
  • AricC
    Recognized Expert Top Contributor
    • Oct 2006
    • 1885

    #2
    Originally posted by 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.
    By break between them do you mean a new line? Use
    Code:
    <br />

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      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

      • html on wheels
        New Member
        • Feb 2007
        • 35

        #4
        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

        • drhowarddrfine
          Recognized Expert Expert
          • Sep 2006
          • 7434

          #5
          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

          • html on wheels
            New Member
            • Feb 2007
            • 35

            #6
            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

            • jhardman
              Recognized Expert Specialist
              • Jan 2007
              • 3405

              #7
              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

              • drhowarddrfine
                Recognized Expert Expert
                • Sep 2006
                • 7434

                #8
                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

                • TNT
                  New Member
                  • Feb 2007
                  • 48

                  #9
                  You could try using
                  [HTML]<fieldset>
                  <legend>...Grou p title...legend>
                  ...radio buttons...
                  </fieldset>[/HTML]

                  Comment

                  • jhardman
                    Recognized Expert Specialist
                    • Jan 2007
                    • 3405

                    #10
                    Originally posted by drhowarddrfine
                    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("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

                    • html on wheels
                      New Member
                      • Feb 2007
                      • 35

                      #11
                      What language is this, jhardman?

                      myVar = request.form("c ategory")

                      Didn't take you very long to leave me in the dust.

                      Comment

                      • jhardman
                        Recognized Expert Specialist
                        • Jan 2007
                        • 3405

                        #12
                        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

                        • drhowarddrfine
                          Recognized Expert Expert
                          • Sep 2006
                          • 7434

                          #13
                          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

                          Working...