vendredi 10 avril 2020

Highlight the border of my check box with JS script

This script worked 20 years ago, I haven't touched JS since. I need it for my language student but can't figure out the problem. I suspect Verif function is out of phase and the style.border attributes are wrong ? Validate doesn't show the border element, solutions work but doesn't show the color either. Is it syntax or wrong method ? Thanks for helping.

function verif(question) {
  if ((question.cas1.checked) == true) {
    question.cas1.style.border = '2px #FF0000 solid';
  }
  if ((question.cas2.checked) == true) {
    question.cas2.style.border = '2px #00CC00 solid';
  }
  if ((question.cas3.checked) == true) {
    question.cas3.style.border = '2px #FF0000 solid';
  }
}
function getCheckAnswers() {
  question.cas2.checked = 'true';
  question.cas2.style.border = '2px #00CC00 solid';
}

function reloadPage() {
  location.reload(true);
}
<FORM  name="question">
  <br>
  <br>
  <b>1.</b>This is a non working JS I am just a language teacher<BR>
  <INPUT type="checkbox" name="cas1">
  French   <INPUT type="checkbox" name="cas2">
 Dutch
  <INPUT type="checkbox" name="cas3">
  English <BR>   <BR>
 <BR>
  <input type="button" value="Validate" name="Test" onClick="verif(question)" class=input1>   
  <input type="button" value="solutions" onclick="getCheckAnswers()" class=input1>
<input type="button" value="startagain" onclick="reloadPage()" class=input1>
</FORM>



Aucun commentaire:

Enregistrer un commentaire