I have a few radio buttons. One of them should enable a (date) field if checked, while all others should not care about this field at all.
When this radio button is checked, the date field should be enabled. I've done this and works. How I'm doing it is calling a function using onClick(). then if the status if the radio button's check is true, I enable the field. (This is because I don't want every click to enable it, such as a click to uncheck the radio button).
The problem:
If one of the other radio buttons are selected, I want the date field to be disabled WITHOUT having to add an onclick() to the rest of them to disable it.
of course onuncheck event doesn't exist. so I have to call a disableDate() function on the last two.
Why I don't like this solution:
Just basic programming standards. Why should the radio buttons be tied, or in this case "clean up after each other".
If you have any thoughts, please share,
thanks,
PS: Feel free to move this or copy this to the JavaScript forum too.
Dan
When this radio button is checked, the date field should be enabled. I've done this and works. How I'm doing it is calling a function using onClick(). then if the status if the radio button's check is true, I enable the field. (This is because I don't want every click to enable it, such as a click to uncheck the radio button).
The problem:
If one of the other radio buttons are selected, I want the date field to be disabled WITHOUT having to add an onclick() to the rest of them to disable it.
Code:
// What I want: <input type="radio" name="one" onclick="enableDate()" onuncheck="disableDate" /> <input type="radio" name="two" /> <input type="radio" name="three" /> // What I don't want to do: <input type="radio" name="one" onclick="enableDate()" /> <input type="radio" name="two" onclick="disableDate()" /> <input type="radio" name="three" onclick="disableDate()" />
Why I don't like this solution:
Just basic programming standards. Why should the radio buttons be tied, or in this case "clean up after each other".
If you have any thoughts, please share,
thanks,
PS: Feel free to move this or copy this to the JavaScript forum too.
Dan
Comment