Quantcast
Channel: Adobe Community : Popular Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 14291

Disabling Fields based on radio button

$
0
0
I have three radio buttons and one input field. The input field corresopnds to button 2 only, and buttons 1 and 3 are just by themselves. What I want to do is if buttons 1 or 3 are selected, then the input field for button two should be disabled/grayed out. If they change their mind and check button 2 instead, then it should be enabled/white out, to accept an entry. What is happening is when I check buttons 1 or 3, the input field does become gray. But when I click on button 2, the input field remains gray/disabeld, and I am not sure how to enable it again. I think it is something simple but I just cannot see it. Please help, thanks

Here is my javascript below, and the radio buttons :

<script type="text/javascript">
function enableFields(fieldList) {
var fieldArray = fieldList.split(',');

// disable all fields
for (var i=1; i<=1; i++) {
document.getElementById('input1').value =""; // clear out the value first (optional)
document.getElementById('input1').disabled = true;
document.getElementById('input1').style.backgroundColor="gray";
}

// enable the fields passed to the function
for (var i=0; i<fieldArray.length; i++) {
document.getElementById('input' + fieldArray).disabled = false;
document.getElementById('input' + fieldArray
).style.backgroundColor="white";
}
}
</script>

<td valign="top">
<input type="radio" name="quantity_type" value="None Given">
None Given<br>
<input type="radio" name="quantity_type" value="Single Lot" onclick="enableFields('1');">
Single Lot with Quantity :
<input type="text" name="quantity" id="input1" disabled="true"><br>
<input type="radio" name="quantity_type" value="Multiple Lots">
Multiple Lots (Specifiy quantities in Additional Information Box)
</td>

Viewing all articles
Browse latest Browse all 14291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>