select the form tag and apply the behavior to the onchange event of the form tag, then cut the code from the onchange event that is generated and paste it to a new script tag at the end of the page:
so you will have the form tag with the onchange to set the form from the cookies:
<form ...... onchange="<set form from cookie code>"
copy the code from the onchange event to a new script tag:
<set form from cookie code>
This will execute the code when the page is loaded.