<select id="Drop1">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<input type="text" id="Text1" disabled="disabled" />
And for example you want Text1 enabled if Drop1 = 3, then
$("#Drop1").change(function() {
if ($(drp).val() == "3") {
$("#Text1").removeAttr("disabled");
}
else {
$("#Text1").attr("disabled", "disabled");
}
});
On Oct 31, 10:34 pm, stvwlf <stv...@gmail.com> wrote:
> Hi
>
> I am new to jQuery - appreciate some help.
>
> I found some code that hides a textbox when a dropdown is set to a
> specific value. That works fine.
>
> $(document).ready(function(){
> if($('select[name=costType] :selected').val() == 'fr'){
> $('input[name=costValue]').disabled();
> }
> });
>
> What I would like to do is not hide the textbox but disable it. I
> would also like text box's contents cleared when it is being
> disabled. If the user goes back and selects a different value in the
> dropdown, the textbox to be enabled, with no value in it.
>
> The dropdown name is costType and it has 3 possible values. Only one
> of them is to trigger disabling the text box.
>
> Thank you for your help
> Steve
No comments:
Post a Comment