473,769 Members | 6,499 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 33851
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(e lem) {
if (currentEnabled ) {
currentEnabled. disabled = true;
}
elem.disabled = false;
currentEnabled = elem;
}
</script>
<form action="">
<input type="text" name="inp1" disabled="disab led">
<input type="radio" name="sel" value="1"
onclick="enable Element(this.fo rm.elements['inp1']);">
<br>
<input type="text" name="inp2" disabled="disab led">
<input type="radio" name="sel" value="2"
onclick="enable Element(this.fo rm.elements['inp2']);">
<br>
<input type="text" name="inp3" disabled="disab led">
<input type="radio" name="sel" value="3"
onclick="enable Element(this.fo rm.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/rasterTriangleD OM.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(e lem) {
if (currentEnabled ) {
currentEnabled. disabled = true;
}
elem.disabled = false;
currentEnabled = elem;
}
</script>
<form action="">
<input type="text" name="inp1" disabled="disab led">
<input type="radio" name="sel" value="1"
onclick="enable Element(this.fo rm.elements['inp1']);">
<br>
<input type="text" name="inp2" disabled="disab led">
<input type="radio" name="sel" value="2"
onclick="enable Element(this.fo rm.elements['inp2']);">
<br>
<input type="text" name="inp3" disabled="disab led">
<input type="radio" name="sel" value="3"
onclick="enable Element(this.fo rm.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/rasterTriangleD OM.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
2995
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
4254
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 is selected - enable a field to use the M$ Datepicker. Using the code below works for most of our fields, however the problem is that when the field is re-enabled - it remembers the original date or data prior to it being disabled - despite the...
3
3542
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 selects one item out of the 'all selected' listing then there is now only one item selected. How and where can I put in some code to change the selected radio button to the 'include' since it is no longer in select all mode. Thanks, Alpha
2
2317
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 add that it behaves fine in Firefox, but IE is unable to re-enable the radio button. IE is fine if the radio button starts in an enabled state.
1
3017
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: (RADIO BUTTON) djs: (RADIO BUTTON) hfjd: Can anyone please help me.. Thanks
2
10091
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 another radio button is selected, then the 1st textbox should disappear and should display in front of the new radio button selected. Following is my code: <html> <head> <script type="text/javascript">
2
5077
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 doesn't seem to be working. Here is my code. Thanks for your help. -sammie <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Nursing Conference 2007 Registration Form</title>
11
9298
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 the code. but radio button is not getting enabled, it just blinks and get disabled. this is the code... radio button is disabled by default.<select name="tak" class="style21" onChange="tlkdisp(document.form1)">function tlkdisp(Object) { var...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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 we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.