You should use javascript (or JQuery, which is a javascript library) to do this, but since $fullname is probably a PHP variable you will need to use that too.
A simple javascript example (which can probably done a bit neater with JQuery) that uses the php variable:
<input id="fullname" type="text" name="fullname" />
<input id="same" name="same" type="checkbox"
onchange="javascript:samename('<?php echo htmlspecialchars($fullname) ?>')" />
this calls a javascript function that should look something like
function samename(fullname) {
same = document.getElementById('same');
full = document.getElementById('fullname');
if(same.checked) {
full.value = fullname;
} else {
full.value = '';
}
}