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.
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
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..
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 -
-
<input type="radio" name="dedupe" value="dedupe1" onclick="enableDisable(this.form, 'CurrentAddress', new Array('PermanentAddress', 'WorkAddress'))" />
-
<input name="CurrentAddress" type="text" disabled="disabled" />
-
-
<input type="radio" name="dedupe" value="dedupe2" onclick="enableDisable(this.form, 'PermanentAddress',new Array('CurrentAddress', 'WorkAddress'))" />
-
<input name="PermanentAddress" type="text" disabled="disabled" />
-
-
<input type="radio" name="dedupe" value="dedupe3" onclick="enableDisable(this.form, 'WorkAddress',new Array('CurrentAddress', 'PermanentAddress') )" />
-
<input name="WorkAddress" type="text" disabled="disabled" />
-
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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.
...
|
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...
|
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...
| |
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: 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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |