I have two input field of type number Field1 and field2 on Opportunity page .
Here is my requirement
If i enter field1= 5 then field2 should auto populate 30+5=35 on the same screen.
I am struggling in it since 2 days.
Please help me out.
Thanks in advance!
Best Answer
Add an
onchange
attribute to theapex:inputField
(Field1) that calls a JavaScript function when Field1 is changed to evaluate the value you want for Field2, e.g.:Take care in accessing VF elements from JavaScript, as it can be a little frustrating based on how Visualforce generates the HTML - you can either use $Component or use the generated element tree syntax.