473,513 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enabling certain text fields corresponding to the selected radio button

3 New Member
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, the text field corresponding to that should be enabled and the other two address type fields should be disabled. This is working fine for the first radio button. But for the other two radio buttons also, the first address type field only gets enabled. The corresponding address type fields for second and third radio button is not getting activated.

Please help me to solve this issue in javascript

Thanks in advance.
Aug 11 '08 #1
4 2737
gits
5,390 Recognized Expert Moderator Expert
please post the code that makes the problem ... so that we may have a closer look at it and could give you hints to fix that problem ...

kind regards
Aug 11 '08 #2
padmapriya
3 New Member
Thanks a lot for your quick response...Hope i had given the clear picture of what i said. Please go through it and provide me the solution.


[HTML]<html>
<head>
<title></title>
<script type="text/javascript">
function init(){
//disable text fields
var f = document.inputForm;
f.CurrentAddress.disabled = true;
f.PermanentAddress.disabled = true;
f.WorkAddress.disabled = true;
}

function enableDisable(oFrm, enabledFldName, disabledFldNames){
oFrm.elements[enabledFldName].disabled = false;
if (disabledFldNames instanceof Array){ //multiple field names
var len = disabledFldNames.length;
for (var i=0; i<len; i++){
oFrm.elements[disabledFldNames[i]].disabled = true;
}
}
else{ //single field name
oFrm.elements[disabledFldNames].disabled = true;
}
}
</script>


<td>

<input type="radio" name="dedupe" value="dedupe1" onclick="enableDisable(this.form, 'CurrentAddress', 'PermanentAddress', 'WorkAddress')" /></td>
<td><input name="CurrentAddress" type="text" /></td>

<input type="radio" name="dedupe" value="dedupe2" onclick="enableDisable(this.form, 'PermanentAddress','CurrentAddress', 'WorkAddress')" /></td>
<td><input name="PermanentAddress" type="text" /></td>

<input type="radio" name="dedupe" value="dedupe3" onclick="enableDisable(this.form, 'WorkAddress','CurrentAddress', 'PermanentAddress' )" /></td>
<td><input name="WorkAddress" type="text" /></td>
[/HTML]
***The current address, permanent address and work address contain sub- fields such as address line1, address line 2, address line 3, city, pincode etc..
Aug 12 '08 #3
vee10
141 New Member
Hi,

in the script function u are comparing the disabledFldNames as an instance of array or not but while calling the fuction u r sending it as an array so always it will be false so the previous one which is enabled will not disabled

forexample u first select the radio button 2 so permant address one will be enabled now u selected the radio button 3 and now the disabledFldNames will be only the currentAddress not the array so it is not an instance so only the currentAddress will be disabled not the permant address

i hope u understood what i am saying

Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="radio" name="dedupe" value="dedupe1" onclick="enableDisable(this.form, 'CurrentAddress', new Array('PermanentAddress', 'WorkAddress'))" />
  3. <input name="CurrentAddress" type="text" disabled="disabled" />
  4.  
  5. <input type="radio" name="dedupe" value="dedupe2" onclick="enableDisable(this.form, 'PermanentAddress',new Array('CurrentAddress', 'WorkAddress'))" />
  6. <input name="PermanentAddress" type="text" disabled="disabled" />
  7.  
  8. <input type="radio" name="dedupe" value="dedupe3" onclick="enableDisable(this.form, 'WorkAddress',new Array('CurrentAddress', 'PermanentAddress') )" />
  9. <input name="WorkAddress" type="text" disabled="disabled" />
  10.  
  11.  
Aug 12 '08 #4
padmapriya
3 New Member
Once again thanks for the reply. Still the first radio button is only working. Even i clicked the other two, the first text field(Current address) is only activated.

I guess u understood like what radio button i clicked first is enabling its corresponding text field. But its not so. Whatever i clicked first, only the first radio button is working. Even If i clicked the second radio button first, the text fields of first button (Current address) is only enabled. So, waiting for the solution again.
Aug 12 '08 #5

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

Similar topics

4
4093
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
2272
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...
1
2568
by: PeeZee | last post by:
I am having some trouble getting this done. I am able to get the value to display on a seperate page but not on the same page in the same form. I would like to display to set value of the radio...
5
3354
by: tshad | last post by:
Is there a way to allow a user to press a radio button if it is already selected? There is an onCheckedChanged event that fires when the person presses the button and it is isn't selected...
1
3441
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...
3
3970
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
8
2011
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
3
1523
by: mukeshrasm | last post by:
Hi I wanted to click any where in the text and the corresponding radio button should get selected. like <input type =radiobutton>mukesh <input type =radiobutton>kumar <input type...
4
3014
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. ...
0
7162
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...
1
7101
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
7527
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...
0
5686
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,...
1
5090
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
3223
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1597
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
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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.