Checkbox onchange?

trying to get a checkbox to change the value of a <input>

so lets say

<input type=“checkbox” name=“change” value=“yes”>

when checked , will onchange this input

<input type=“hidden” name=“required” value=“companyname,realname”>

i really havent gotten a grasp on how functions work or how they are coded but i really need major help with this one. Any help is appreciated