所以,任何暗示为什么这不起作用? 如果选择'Boleto'radiobox('1'和'MercadoPago',分别返回到用户输入,并且如果选择'Boleto'radiobox',则试图在预设中同时获得两个输入字段('pagamento'和'parcelas') '卡唐' radiobox选择。DOM事件链接不工作
function boleto() {
if(document.getElementById('tipodepagamento').checked==true){
document.getElementById('pagamento').value = 'MercadoPago';
document.getElementById('pagamento').disabled = true;
document.getElementById('parcelas').value = '1';
document.getElementById('parcelas').disabled = true;
}
else{
document.getElementById('pagamento').disabled = false;
document.getElementById('parcelas').disabled = false;
}
}
<div class="col-md-6">
<label class="radio-inline">
<input type="radio" name="tipodeconta" id="tipodepagamento2" value="Cartão" checked onClick="boleto();">Cartão de Crédito
</label>
</div>
<div class="col-md-6">
<label class="radio-inline">
<input type="radio" name="tipodeconta" id="tipodepagamento" value="Boleto" onClick="boleto();">Boleto
</label>
</div>
<label>Plataforma de Pagamento</label>
<select class="form-control" onClick="fpagamento();validador();" onKeyUp="fpagamento();" name="pagamento" id="pagamento">
<option value="Selecione">Selecione</option>
<option value="Paypal">Paypal</option>
<option value="MercadoPago">Mercado Pago</option>
</select>
<label>Número de Parcelas</label>
<select class="form-control" id="parcelas" name="parcelas">
<option value="1">1x</option>
<option value="2">2x</option>
</select>
的document.getElementById( 'pagamento')值= 'MercadoPago'。 document.getElementById('pagamento')。value ='1';你在这里设置两次相同的字段。我想第二行你需要为parcelas设置价值。 –
你可以添加你的'html'代码吗? – BSeitkazin
何时执行“boleto”?您可能在DOM存在之前运行/绑定该函数。 – 4castle