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

239
Visualizações
Can't use user inputs from options and text fields in a function

I'm pretty new to programming, I'm trying to get the user input of the options from "province" and the value from "income" and use it in the js function below, but I can't figure out what's wrong.

<div class="taxform">
  <form>
    <label for="province">Please select your province from the list below: </label>
    <select id="province" name="province">
      <option value="0">Select option</option>
      <option value="1">Newfoundland and Labrador</option>
      <option value="2">Prince Edward Island</option>
    </select>
  </form>
  <form>
    <label for="income">Please enter your annual income: </label>
    <input type="number" value="" id="income" name="income">
    <br> <br>
    <button onclick="calculate(document.getElementById('province').value,document.getElementById('income').value)">Calculate</button>
  </form>
function calculate() {
  var percentage;
  var province = province(document.taxform.province.value);
  var income = income(document.taxform.income.value);
  if province = 1 {
    percentage = 20;
  }
  else if province = 2 {
    percentage = 30;
  }
  var res = (income - ((percentage / 100) * income));
  alert(res);
}
about 4 years ago · Juan Pablo Isaza
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