1
I have this html code:
<input type="radio" name="resultado" value="Y" onclick="habilitaCampo(this.value)">Aprovado
<input type="radio" name="resultado" value="N" onclick="habilitaCampo(this.value)">Recusado<br>
<input type="text" id="data_validade" name="data_validade" size="15" maxlength="10" disabled="disabled" onKeyPress="mascara_data(this,event);"/>
And the javascript function:
function habilitaCampo(valor){
if(valor == "Y"){
document.getElementById("data_validade").disabled = false;
document.getElementById("data_validade").focus();
}
else{
document.getElementById("data_validade").disabled = true;
}
}
to enable or disable the field expiration date. But I wanted to pass the id of the field as parameter and be able to use this function in other fields, because I am creating several equal and unnecessary functions, and I can’t pass and receive the value correctly. Can you help me in this matter?
Which field you want to cross?
data_validade
?– Sergio
And because you do not pass the value once in the function: onclick="enable')"?
– Aline
@Sergio that field right!
– thiagofred
@Aline the idea would be this, but is giving error Uncaught Referenceerror: habilitaCampo is not defined at Htmlinputelement.onclick (helpers.php:86) 86 being the radio input line.
– thiagofred