Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

integrating radio buttons with textbox

Posted on 2008-06-23
6
Medium Priority
?
206 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
Industry Leaders: 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!

 
LVL 11

Accepted Solution

by:
spoxox earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

604 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