- Add
data-post_id
attribute to checkbox and fill it with corresponding post ID. - On click on
compare
button (link) retrieve all post ids from checked checkboxes with JavaScript (jQuery) - Redirect to the comparision page with post IDs in url as GET parameters. This is just one scenario how youyour task could be done.
PS your question is not related to WordPress itself but is form field of web application architecture.