Your code basically works - one issue might be the way in which you are selecting the input element. If anything changes on the page the id - "j_id0:j_id2:j_id4:j_id31:j_id34:j_id35", will also change since this describes the elements position in relation to other page elements.
Personally I normally solve this by explicitly adding an id:
You don't need to query the records, just bind directly to the record in the controller:
<apex:page standardController="Opportunity" extensions="Opportunity_UpdExt" docType="html-5.0" sidebar="true" lightningstylesheets="true">