ExecuteAction is not supported in browser-enabled forms. A work around for your problem may be
1) have an additional field(say is_opt_sec_visible) in your form.
2) place conditional formating on optional section if is_opt_sec_visible = "1". hide the field.
3) In the code decide whether the optional section needs to be shown or not. if yes set the value of is_opt_sec_visible to 0, otherwise set is_opt_sec_visible to 1.