473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enable Textbox when radio button selected

Guys,

I have a set of 6 radio buttons, infront of each one there's a textbox
....
i need all textboxes disabled .... once one of the radio buttons is
selected, the texbox infront of it will be anabled to type in ...

any fast solution?

Jun 10 '06 #1
2 33796
te******@gmail.com writes:
I have a set of 6 radio buttons, infront of each one there's a textbox
...
i need all textboxes disabled .... once one of the radio buttons is
selected, the texbox infront of it will be anabled to type in ...


----
<script type="text/javascript">
var currentEnabled = null;
function enableElement(elem) {
if (currentEnabled) {
currentEnabled.disabled = true;
}
elem.disabled = false;
currentEnabled = elem;
}
</script>
<form action="">
<input type="text" name="inp1" disabled="disabled">
<input type="radio" name="sel" value="1"
onclick="enableElement(this.form.elements['inp1']);">
<br>
<input type="text" name="inp2" disabled="disabled">
<input type="radio" name="sel" value="2"
onclick="enableElement(this.form.elements['inp2']);">
<br>
<input type="text" name="inp3" disabled="disabled">
<input type="radio" name="sel" value="3"
onclick="enableElement(this.form.elements['inp3']);">
</form>
----

You might want to have the textboxes enabled by default and use
a script to disable them. Then they still work if Javascript is
disabled.

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 10 '06 #2
Thumbs up,
Thanks a bunch
Lasse Reichstein Nielsen wrote:
te******@gmail.com writes:
I have a set of 6 radio buttons, infront of each one there's a textbox
...
i need all textboxes disabled .... once one of the radio buttons is
selected, the texbox infront of it will be anabled to type in ...


----
<script type="text/javascript">
var currentEnabled = null;
function enableElement(elem) {
if (currentEnabled) {
currentEnabled.disabled = true;
}
elem.disabled = false;
currentEnabled = elem;
}
</script>
<form action="">
<input type="text" name="inp1" disabled="disabled">
<input type="radio" name="sel" value="1"
onclick="enableElement(this.form.elements['inp1']);">
<br>
<input type="text" name="inp2" disabled="disabled">
<input type="radio" name="sel" value="2"
onclick="enableElement(this.form.elements['inp2']);">
<br>
<input type="text" name="inp3" disabled="disabled">
<input type="radio" name="sel" value="3"
onclick="enableElement(this.form.elements['inp3']);">
</form>
----

You might want to have the textboxes enabled by default and use
a script to disable them. Then they still work if Javascript is
disabled.

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'


Jun 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2954
by: Gary | last post by:
Hello, Is it possible to dynamically update a textbox with words chosen from a list using form checkboxes and javascript? Gary
1
4221
by: hortoristic | last post by:
We are using JavaScript to Enable/Disable certain fields on web pages based on business rules. A simple example is if when using an option type tag, and the two options are Yes and No. If YES...
3
3525
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user...
2
2291
by: xazos79 | last post by:
Hi All, I've come across the problem of not being able to re-enable a radio button with javascript if its initial state has been disabled in the Page_Load() method of the code behind. Might i...
1
2971
by: jw01 | last post by:
Im trying to write a java script in HTML in which when a particular radio button is selected, a textbox would appear write next to the selected item. e.g (RADIO BUTTON) fhd: (RADIO BUTTON) fdj:...
2
10066
by: jw01 | last post by:
I changed my code...Now everytime i click a radio button, a text box appears...What i want is when i hit a particular radio button, the textbox should only appear next to that radio button. And if...
2
5039
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it...
11
9256
by: ajaymohank | last post by:
Hello Friends....... in my project i am having a dropdown and based on the values selected from the dropdown, i have to enable 2 radio button. in the on change function of drop down i have written...
0
7125
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
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
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...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.