Make sure you load the js at the beginning of the dom, else the function wont be declared.
function showonlyone(thechosenone) {
$('.newboxes').each(function () {
if ($(this).attr("id") == thechosenone) {
$(this).show();
} else {
$(this).hide();
}
});
}
Also you can enhance the whole function to this:
function showonlyone(thechosenone) {
$('.newboxes:not([data-id='+thechosenone+'])').hide();
$('.newboxes[data-id='+thechosenone+']').show();
}