vendredi 20 décembre 2019

Given two yes/no fields, how can I use JavaScript to make the field 2 value checked "Yes" whenever the field 1 value is checked "Yes"?

If Field 1 is checked "Yes" then Field 2 should be checked "Yes"

This is what I've been trying so far:

Field 1:

<div class="entire">
<div class="col3"><label class="label-right">||FIELDTAG Field1||Question15||ENDFIELDTAG||&nbsp;</label></div>
<div class="col9"><input type="radio" name="Field1" id="Question15yes" value="Yes" onclick="Check()">Yes&nbsp;<input type="radio" name="Field1" value="No" onclick="Check()">No</div>

Field 2:

<div class="entire">
<div class="col3"><label class="label-right">||FIELDTAG Field2||Question16||ENDFIELDTAG||&nbsp;</label></div>
<div class="col9"><input type="radio" name="Field2" id="Question16yes" value="Yes" onclick="Check()">Yes&nbsp;<input type="radio" name="Field2" value="No" onclick="Check()">No</div>

I was trying something as simple as this js below, but I'm definitely missing something. Any help would be greatly appreciated!

<script language="JavaScript">    
function Check()  {
$("#Question15yes").click(function(){
     if ($(this).is(':checked'))
     {
         $("#Question16yes").val("Yes");
     }
        }
      });
    }      
</script>



Aucun commentaire:

Enregistrer un commentaire