Solved

integrating radio buttons with textbox

Posted on 2008-06-23
6
203 Views
Last Modified: 2010-04-09
hi experts,
I have a question that requires a couple of radio button answers.

You get to select one of the 2 radio buttons. If none of them matches your choice, you specify it in the "Other" input textbox.
Please see below for the way I did it:
          <tr>
            <td class=ReviewHeadline>
              <font color="#000000">Religion: </font> </div></td>
            <td  style="border-left:1px dotted black;"><font color="#000000">Methodist?<input name="religion" type="radio" id="religion"></font><font color="#000000">RCIA?<input name="religion" type="radio" id="religion"></font><br>Other?<input name="otherreligion" type="text" id="otherreligion" size="22"></font></td>
          </tr>

As you can see, the radio button name is religion. However, the "Other" option has a different form name = "otherreligion". Is it possible to give textbox option same name as radio button option?

This way, if the 2 choices doesn't meet the user's choice, it can be specified in the "Other" box.

Any ideas? Hope this is not confusing.
0
Comment
Question by:simflex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:spoxox
ID: 21847359
The most common solution to this problem is to add a third radio button for "Other" and include the textbox beside it, often labelled "Specify:".
0
 
LVL 11

Expert Comment

by:spoxox
ID: 21847407
See snippet.
<form name="form1" method="post" action="ee8623c.html">
  <table>
    <tr>
      <td class=ReviewHeadline><font color="#000000">Religion: </font>
        </div></td>
      <td  style="border-left:1px dotted black;"><br>
        <table width="100%" border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td><font color="#000000">Methodist?</font></td>
            <td><font color="#000000">
              <input name="religion" type="radio" id="religion2" value="M">
              </font></td>
            <td><font color="#000000">RCIA?</font></td>
            <td><font color="#000000">
              <input name="religion" type="radio" id="religion3" value="R">
              </font></td>
          </tr>
          <tr>
            <td>Other?</td>
            <td><input name="religion" type="radio" id="religion" value="O"></td>
            <td>Specify: </td>
            <td><input name="otherreligion" type="text" id="otherreligion" size="22"></td>
          </tr>
        </table>
        </font></td>
    </tr>
  </table>
</form>

Open in new window

0
 

Author Comment

by:simflex
ID: 21847567
Thanks for your prompt response.

Just to clarify, please take a look at this snip:

          <tr>
            <td>Other?</td>
            <td><input name="religion" type="radio" id="religion" value="O"></td>
            <td>Specify: </td>
            <td><input name="otherreligion" type="text" id="otherreligion" size="22"></td>
          </tr>

Do I still need the otherreligion box?
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 11

Accepted Solution

by:
spoxox earned 50 total points
ID: 21848169
Do I still need the otherreligion box?

Yes, if you want to know what the other religion is. When you process the form that holds these input fields, you'll need to check the radio buttons first; then if Other is selected, get the text field value.

If you don't need to know what the other religion is, then delete the box.
0
 

Author Comment

by:simflex
ID: 21848683
Ok, thanks.

I will do that and probably extend it a bit by hiding the textbox until the "Other" choice is selected.

Thanks for your assistance.
0
 
LVL 11

Expert Comment

by:spoxox
ID: 21848708
Best of luck!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question