function calculate(form, id) {
  a = form.q1.value;
  b = form.q2.value;

  switch(id) {
    case 1:
      total = (a / 100) * b;
      break;
    case 2:
      total = (a / b) * 100;
      break;
    case 3:
      total = (b - a) / a * 100;
      break;
  }

  form.total.value = total;
}
