Solved

integrating radio buttons with textbox

Posted on 2008-06-23
6
190 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now