I'm currently building a preferences update form (not the main default Marketing Cloud preferences centre, but a specific form for a small audience segment)
I'm pre-populating the form from a personalised link in an email. I've been able to pre-populate the text fields with their existing preferences like so:
<input type="text" id="Firstname" name="Firstname" value="%%=v(@Firstname)=%%" required="" required>
But I am struggling a little with the checkboxes (boolean).
In raw HTML, adding 'checked' as below pre-ticks the checkbox. I've stored this value based on an if statement in a variable
If IndexOf(@StudyRegion,@Region1) > 0 Then Set @RegionNE = "checked" Else Set @RegionNE = "" EndIf
So if they checked that box first time round, the IndexOf section of the query finds it in the string (created as a result of multiple checkboxes) which looks like 'Northern Ireland,Wales,Greater London,East Midlands' etc. If it finds the appropriate region it sets the RegionNE variable to 'checked'. I have tried putting this variable in the checkbox lines like this:
<input type="checkbox" name="Study region" id="North East" value="North East" %%=v(@RegionNE)=%% />
But it's clearly wrong as it causes the page to get a 500 error. What would be the right way of making this checkbox be checked if the variable was found to be 'checked'?