Edit in JSFiddle

<input type="checkbox" data-id="1">
<input type="checkbox" data-id="2">
<button>Click me</button>
button {
  display:none;
}
$('input[type="checkbox"]').click(e=>{
	let cb = $('input[type="checkbox"]:checked');
  if (cb.length) $('button').show(); else $('button').hide();
});

$('button').click(e=>{
	let checked = [];
	$('input[type="checkbox"]:checked').each((i,el)=>{
  checked.push($(el).data('id'));
  });
  if (!checked.length) return;
  let url = '/contact?ids='+checked.join(',');
  alert(url);
});