Solved

integrating radio buttons with textbox

Posted on 2008-06-23
6
197 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

820 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