Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
How to call a function in JavaScript when radio button is selected

I am new to JavaScript, I am trying to call another function but it is not working can someone tell me what am doing wrong. I have a radio button based on the selection i want to call a function.

  const paymentForm = document.getElementById('paymentForm');
  paymentForm.addEventListener("submit", myFunction, false);

 //PaymentMethodRadio: 


 function myFunction() {
 if (document.getElementById('Once').checked) {
  payWithPaystack1.call();

  }

  if (document.getElementById('Reoccuring').checked) {

  }
}

   function payWithPaystack1(e) {
     e.preventDefault();
     let handler = PaystackPop.setup({

key: 'censored', // Replace with your public key
email: document.getElementById("email-address").value,
amount: document.getElementById("amount").value * 100,
ref: '' + Math.floor((Math.random() * 1000000000) + 1), // generates a pseudo-unique reference. Please replace with a reference you generated. Or remove the line entirely so our API will generate one for you
// plan: 'censored',
subaccount: 'censored',

// label: "Optional string that replaces customer email"

onClose: function () {
  alert('Window closed.');
},


callback: function (response) {
  let message = 'Payment complete! Reference: ' + response.reference;
  alert(message);
}
 });
  handler.openIframe();
  }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try to use on or changed events

 $(document.getElementById('Reoccuring')).on('click change', function(e) {
    
  // your checking statements.
  if (document.getElementById('Reoccuring').checked) {
      //checked function 
  } else
  {
      // unchecked
  }
});
about 4 years ago · Juan Pablo Isaza Relatório

0

with If statement like this

if(document.getElementById('radioButtonID').checked) {
// do this
}

check this stack it may help How can I check whether a radio button is selected with JavaScript?

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda