?
Solved

integrating radio buttons with textbox

Posted on 2008-06-23
6
Medium Priority
?
205 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Suggested Courses

777 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