Simple as that little fella:
function disable_select(){
$("#produtos").prop('disabled',true);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="produtos" id='produtos'>
<option value="1">Arroz</option>
<option value="2">Feijão</option>
<option value="3">Macarrão</option>
</select>
<input type="submit" value="Enviar" onclick='disable_select()'>
in the ONclick
button calls the function that disables the field, with this code jQuery:
$("#produtos").prop('disabled',true);
If you want to disable only the option
selected:
function disable_select(){
var id = $('#produtos').children(":selected").attr("id");
$("#"+id).prop('disabled',true);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="produtos" id='produtos'>
<option value="1" id='optArroz'>Arroz</option>
<option value="2" id='optFeijao'>Feijão</option>
<option value="3" id='optMacarrao' onclick='add_opt(optMacarrao)'>Macarrão</option>
</select>
<input type="submit" value="Enviar" onclick='disable_select()'>
Can you explain why you need to disable the button after Submit? You may not really need it.
– Caique Romero
This after the Submit?
– Sam
Tah using PHP?
– Sam