473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to make a text box enabled when radio button is selected - please help

Hello,

I am a newbie with Javascript. I have this question. I have created a form with 3 radio buttons, (male, female, other), whenever a user click on other, I like to have the text box enabled (it is disbled by default, greyed out).

<input type="radio" name="gender" id="m" value="male" />Male
<input type="radio" name="gender" id="f" value="female" />female
<input type="radio" name="gender" id="other" value="Other" />Other
<input type="text" size="20" maxlength="50" name="Othertxt" disabled="disabled" id="other" />

Is there any way to do it in JS???

Big thanks.

Jenny.
Mar 15 '07 #1
4 2175
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <input type="radio" name="gender" id="m" value="male" onclick="document.getElementById('otherinput').disabled=true;">Male
  2. <input type="radio" name="gender" id="f" value="female" onclick="document.getElementById('otherinput').disabled=true;">female
  3. <input type="radio" name="gender" id="other" value="Other" onclick="document.getElementById('otherinput').disabled=false;">Other
  4. <input type="text" size="20" maxlength="50" name="Othertxt" id="otherinput" disabled="disabled">
  5.  

two id's can't be the same on the same page so i changed it
Mar 15 '07 #2
Big thanks, that works.
thanks.
Mar 15 '07 #3
acoder
16,027 Expert Mod 8TB
Is there another gender besides male and female?! Am I missing something?
Mar 16 '07 #4
iam_clint
1,208 Expert 1GB
Shemale, Transvestite?

I dunno! :P
Mar 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
5
by: Dan | last post by:
Hi, I'm going crazy here, please help. I have a parent page that has a user control on it that bubbles up data from a dropdown menu. The drop down menus are populated by a set of radio buttons,...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: namanhvu | last post by:
Hi everyone, I'm trying to create a form where the radio button is automatically selected when the input text field beside it is clicked. I know I need to use "onClick" somewhere but I don't...
4
by: padmapriya | last post by:
I need to create three radio buttons and when the radio button is clicked, the corresponding text fields such as 3 different address types should get activated. If i clicked the first radio button,...
4
by: pureadrenaline | last post by:
Hey Guys, Please could anyone help me out with the following form I need to create a validation on the email field only if the user checked the radio button named Email. Thanks in advance. ...
11
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.