i dont honestly know enough about how your page is configured to be able to tell you where to put the code.
I guess you could do it directly in the form element using:
<input type="text" name="Spectrum_online_7_Pages_Add" value="<?php echo (($_GET['pgx']-40<0)?0:$_GET['pgx']-40); ?>" />