0
Hello everyone As I have no experience with javascript I would like a help how to disable some specific fields.
In this Script below and is exactly what I need only when putting it in the code It disables fields that don’t need to be disabled. I would like to know how this code can be changed to only for some fields containing example.. an id=x
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(document).ready(function() {
$("#enable").click(function (){
// habilita o campo
$("input").prop("disabled", false);
$("select").prop("disabled", false);
});
$("#disable").click(function (){
// desabilita o campo
$("input").prop("disabled", true);
$("select").prop("disabled", true);
});
});
});//]]>
</script>
<button href="#" id="enable" >Habilita Campos</button>
<button href="#" id="disable" >Desabilita Campos</button>
<input type="text" id="campo" name="campo1" disabled/> <br/>
<input type="text" id="campo" name="campo2" disabled/> <br/>
<input type="text" name="campo3" disabled/> <!--exemplo Não fazer nada -->
You cannot have different elements with the same ID. It’s always the same input you want to disable?
– Sergio
Let’s say I have 10 inputs, but I just want to enable/disable 4
– Fabio Henrique
What I want to know is how you choose them, so I can answer.
– Sergio
Yes I have to choose more I don’t know where you can make that choice, or if it could be like this, everyone who has id="1", id="2", id="3"
– Fabio Henrique