The way I'd do your particular script is set an include to output just the result from the form, and place it in the directory structure where it can be called both server-side and client-side. Call it server-side in the usual way...
// create page before form output
// create page after form output
<input type="submit" onclick="changeScript('formOutput.php?live=1&formValue1='+input1.value+'&formValue2='+input2.value); return false" />
To output just the string you require without executing the rest of the page (or skipping the bits that output when live is false)
I hope you've got the gist of it. I'm not very good at writing about it. Good at using it though