Search the Community
Showing results for tags 'disable'.
-
Hi there, I have 10 drop down boxes on a page where people can select some units they wish to study. Obviously people can pick more than one unit and so i want to avoid them from picking the same unit twice in each of the drop down boxes. I have looked into the disable function on drop down boxes but cannot figure out how i would go about disabling a drop down selection entry using Javascript. So far i have looked at the following jquery function below but it will not work on my php page as i do not have access to the head of the document on the platform i am on and just the body: $('select').change(function() { var ary = new Array(); $('select option:selected').each(function() { if ($(this).val().length > 0) { ary.push($(this).val()); } }); $('select option').each(function() { if ($.inArray($(this).val(), ary) > -1) { $(this).attr('disabled', 'disabled'); } else { $(this).removeAttr('disabled'); } });}); The example above is the sort of thing i am after but having studied the code, without it being in the head of the document it will not work and so it does not work when i change entry in the dropdown list. Does anybody have any modifications to the code or examples i can use to find out the values of all other dropdown's on a form and to then disable an index in the others where one is already selected on that index? Obviously i would need something to enable selections again. Even an alert box stating that the unit has already been picked and resetting back to original value would do. Many thanks, Mark
-
I'd like to disable certain input boxes, but without changing the HTML code manually. For example:I'd like to disable the input boxes with the following id's:id="first_field"id="fourth_field"id="sixth_field" <div> <form action=""> <fieldset> <input type="text" id="first_field"/> <input type="text" id="second_field"/> <input type="text" id="third_field"/> <input type="text" id="fourth_field"/> <input type="text" id="fifth_field"/> <input type="text" id="sixth_field"/> </fieldset> </form> </div> Anyone know a Javascript that can do this?